diff options
-rw-r--r-- | compiler/GHC/CmmToAsm/X86/CodeGen.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_compile/T18614.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_compile/all.T | 2 |
3 files changed, 19 insertions, 2 deletions
diff --git a/compiler/GHC/CmmToAsm/X86/CodeGen.hs b/compiler/GHC/CmmToAsm/X86/CodeGen.hs index 0f982b8d56..4480848b90 100644 --- a/compiler/GHC/CmmToAsm/X86/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/X86/CodeGen.hs @@ -1052,7 +1052,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- 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 @@ -1061,7 +1063,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- 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: diff --git a/testsuite/tests/codeGen/should_compile/T18614.hs b/testsuite/tests/codeGen/should_compile/T18614.hs new file mode 100644 index 0000000000..ae055e3cfd --- /dev/null +++ b/testsuite/tests/codeGen/should_compile/T18614.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} +{-# OPTIONS_GHC -O #-} + +module Main where + +import GHC.Exts + +main = pure () + +test :: Word8# -> Word8# +test x = x `plusWord8#` narrowWord8# 1## diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T index cb61b2b44c..0e89b1d82c 100644 --- a/testsuite/tests/codeGen/should_compile/all.T +++ b/testsuite/tests/codeGen/should_compile/all.T @@ -101,3 +101,5 @@ test('T15570', compile, ['-Wno-overflowed-literals']) # skipped with CmmToC because it generates a warning: # warning: integer constant is so large that it is unsigned + +test('T18614', normal, compile, ['']) |