From: Eli Friedman Date: Thu, 14 Jul 2016 05:48:25 +0000 (+0000) Subject: [X86] Fix stupid typo in isel lowering. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=940c90777fda3847fbfd3e5029ad8cd088212ae2;p=llvm [X86] Fix stupid typo in isel lowering. Apparently someone miscounted the number of zeros in the immediate. Fixes https://llvm.org/bugs/show_bug.cgi?id=28544 . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275376 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86InstrCompiler.td b/lib/Target/X86/X86InstrCompiler.td index 7cd4f979642..925f4efb5aa 100644 --- a/lib/Target/X86/X86InstrCompiler.td +++ b/lib/Target/X86/X86InstrCompiler.td @@ -1405,7 +1405,7 @@ def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst), // instructions. def : Pat<(add GR64:$src1, 0x0000000080000000), (SUB64ri32 GR64:$src1, 0xffffffff80000000)>; -def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst), +def : Pat<(store (add (loadi64 addr:$dst), 0x0000000080000000), addr:$dst), (SUB64mi32 addr:$dst, 0xffffffff80000000)>; // To avoid needing to materialize an immediate in a register, use a 32-bit and diff --git a/test/CodeGen/X86/add.ll b/test/CodeGen/X86/add.ll index 62a62a460bd..df1bc9b6ee7 100644 --- a/test/CodeGen/X86/add.ll +++ b/test/CodeGen/X86/add.ll @@ -148,3 +148,39 @@ entry: ; X64: incl ; X64-NEXT: seto } + +define void @test11(i32* inreg %a) nounwind { + %aa = load i32, i32* %a + %b = add i32 %aa, 128 + store i32 %b, i32* %a + ret void +; X32-LABEL: test11: +; X32: subl $-128, (% +; X64-LABEL: test11: +; X64: subl $-128, (% +} + +define void @test12(i64* inreg %a) nounwind { + %aa = load i64, i64* %a + %b = add i64 %aa, 2147483648 + store i64 %b, i64* %a + ret void +; X32-LABEL: test12: +; X32: addl (% +; X32-NEXT: adcl $0, +; X64-LABEL: test12: +; X64: subq $-2147483648, (% +} + +define void @test13(i64* inreg %a) nounwind { + %aa = load i64, i64* %a + %b = add i64 %aa, 128 + store i64 %b, i64* %a + ret void + +; X32-LABEL: test13: +; X32: addl (% +; X32-NEXT: adcl $0, +; X64-LABEL: test13: +; X64: subq $-128, (% +}