Commit 81560981 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot
Browse files

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

parent b790b7f9
Pipeline #27172 failed with stages
in 520 minutes and 53 seconds
...@@ -1052,7 +1052,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps ...@@ -1052,7 +1052,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps
-------------------- --------------------
add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register
add_code rep x (CmmLit (CmmInt y _)) 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 add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y
where format = intFormat rep where format = intFormat rep
-- TODO: There are other interesting patterns we want to replace -- TODO: There are other interesting patterns we want to replace
...@@ -1061,7 +1063,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps ...@@ -1061,7 +1063,9 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps
-------------------- --------------------
sub_code :: Width -> CmmExpr -> CmmExpr -> NatM Register sub_code :: Width -> CmmExpr -> CmmExpr -> NatM Register
sub_code rep x (CmmLit (CmmInt y _)) 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 sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y
-- our three-operand add instruction: -- 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##
...@@ -101,3 +101,5 @@ test('T15570', ...@@ -101,3 +101,5 @@ test('T15570',
compile, ['-Wno-overflowed-literals']) compile, ['-Wno-overflowed-literals'])
# skipped with CmmToC because it generates a warning: # skipped with CmmToC because it generates a warning:
# warning: integer constant is so large that it is unsigned # warning: integer constant is so large that it is unsigned
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