[PATCH] D43549: [ARM] Fix issue with large xor constants.
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 02:13:51 PST 2018
dmgreen created this revision.
dmgreen added reviewers: efriedma, spatel.
Herald added subscribers: kristof.beyls, javed.absar.
Fixup to https://reviews.llvm.org/rL325573 for large xor constants.
Thanks to Eli Friedman for the catch.
https://reviews.llvm.org/D43549
Files:
lib/Target/ARM/ARMTargetTransformInfo.cpp
test/CodeGen/Thumb/mvn.ll
Index: test/CodeGen/Thumb/mvn.ll
===================================================================
--- test/CodeGen/Thumb/mvn.ll
+++ test/CodeGen/Thumb/mvn.ll
@@ -191,3 +191,32 @@
ret void
}
+
+define void @test128(i128* %a) {
+; CHECK-LABEL: test128:
+; CHECK: ldr r1, [r0, #4]
+; CHECK-NEXT: ldr r2, .LCPI8_0
+; CHECK-NEXT: eors r2, r1
+; CHECK-NEXT: str r2, [r0, #4]
+; CHECK-NEXT: ldr r1, [r0]
+; CHECK-NEXT: ldr r2, .LCPI8_1
+; CHECK-NEXT: eors r2, r1
+; CHECK-NEXT: str r2, [r0]
+; CHECK-NEXT: ldr r1, [r0, #8]
+; CHECK-NEXT: ldr r2, .LCPI8_2
+; CHECK-NEXT: eors r2, r1
+; CHECK-NEXT: str r2, [r0, #8]
+; CHECK-NEXT: bx lr
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: .LCPI8_0:
+; CHECK-NEXT: .long 4075008415
+; CHECK-NEXT: .LCPI8_1:
+; CHECK-NEXT: .long 2080661269
+; CHECK-NEXT: .LCPI8_2:
+; CHECK-NEXT: .long 6692605
+ %x = load i128, i128* %a
+ %xn = xor i128 %x, 123456789123456789123456789
+ store i128 %xn, i128* %a
+ ret void
+}
+
Index: lib/Target/ARM/ARMTargetTransformInfo.cpp
===================================================================
--- lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -127,11 +127,8 @@
}
// xor a, -1 can always be folded to MVN
- if (Opcode == Instruction::Xor) {
- int64_t NegImm = Imm.getSExtValue();
- if (NegImm == -1)
- return 0;
- }
+ if (Opcode == Instruction::Xor && Imm.isAllOnesValue())
+ return 0;
return getIntImmCost(Imm, Ty);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43549.135205.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180221/7c2e4b7e/attachment.bin>
More information about the llvm-commits
mailing list