Commit 47859207 authored by Sylvain Henry's avatar Sylvain Henry Committed by Ben Gamari
Browse files

Don't use LEA with 8-bit registers (#18614)

(cherry picked from commit 81560981)
parent 96c86456
......@@ -1055,7 +1055,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = do -- dyadic MachOps
--------------------
add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register
add_code rep x (CmmLit (CmmInt y _))
| is32BitInteger y = add_int rep x y
| is32BitInteger y
, rep /= W8 -- LEA doesn't support byte size (#18614)
= add_int rep x y
add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y
where format = intFormat rep
-- TODO: There are other interesting patterns we want to replace
......@@ -1064,7 +1066,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = do -- dyadic MachOps
--------------------
sub_code :: Width -> CmmExpr -> CmmExpr -> NatM Register
sub_code rep x (CmmLit (CmmInt y _))
| is32BitInteger (-y) = add_int rep x (-y)
| is32BitInteger (-y)
, rep /= W8 -- LEA doesn't support byte size (#18614)
= add_int rep x (-y)
sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y
-- our three-operand add instruction:
......
{-# LANGUAGE MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -O #-}
module Main where
import GHC.Exts
main = pure ()
test :: Word8# -> Word8#
test x = x `plusWord8#` narrowWord8# 1##
......@@ -89,3 +89,4 @@ switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default:
test('T14373d', [],
multimod_compile_filter, ['T14373d', '-fasm -O2 -c -ddump-cmm-from-stg',
switch_skeleton_and_entries_only])
test('T18614', normal, compile, [''])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment