Commit febd6d9a authored by Simon Marlow's avatar Simon Marlow
Browse files

x86_64: fix case of out-of-range operands to leaq

parent eba7b660
...@@ -1113,12 +1113,14 @@ getRegister e@(CmmMachOp mop [x, y]) -- dyadic MachOps ...@@ -1113,12 +1113,14 @@ getRegister e@(CmmMachOp mop [x, y]) -- dyadic MachOps
-------------------- --------------------
add_code :: MachRep -> CmmExpr -> CmmExpr -> NatM Register add_code :: MachRep -> CmmExpr -> CmmExpr -> NatM Register
add_code rep x (CmmLit (CmmInt y _)) = add_int rep x y add_code rep x (CmmLit (CmmInt y _))
| not (is64BitInteger y) = add_int rep x y
add_code rep x y = trivialCode rep (ADD rep) (Just (ADD rep)) x y add_code rep x y = trivialCode rep (ADD rep) (Just (ADD rep)) x y
-------------------- --------------------
sub_code :: MachRep -> CmmExpr -> CmmExpr -> NatM Register sub_code :: MachRep -> CmmExpr -> CmmExpr -> NatM Register
sub_code rep x (CmmLit (CmmInt y _)) = add_int rep x (-y) sub_code rep x (CmmLit (CmmInt y _))
| not (is64BitInteger (-y)) = add_int rep x (-y)
sub_code rep x y = trivialCode rep (SUB rep) Nothing x y sub_code rep x y = trivialCode rep (SUB rep) Nothing x y
-- our three-operand add instruction: -- our three-operand add instruction:
...@@ -1972,13 +1974,16 @@ getRegOrMem e = do ...@@ -1972,13 +1974,16 @@ getRegOrMem e = do
return (OpReg reg, code) return (OpReg reg, code)
#if x86_64_TARGET_ARCH #if x86_64_TARGET_ARCH
is64BitLit (CmmInt i I64) = i > 0x7fffffff || i < -0x80000000 is64BitLit (CmmInt i I64) = is64BitInteger i
-- assume that labels are in the range 0-2^31-1: this assumes the -- assume that labels are in the range 0-2^31-1: this assumes the
-- small memory model (see gcc docs, -mcmodel=small). -- small memory model (see gcc docs, -mcmodel=small).
#endif #endif
is64BitLit x = False is64BitLit x = False
#endif #endif
is64BitInteger :: Integer -> Bool
is64BitInteger i = i > 0x7fffffff || i < -0x80000000
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- The 'CondCode' type: Condition codes passed up the tree. -- The 'CondCode' type: Condition codes passed up the tree.
......
Markdown is supported
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