diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-02-12 17:07:47 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-02-12 17:07:47 +0000 |
commit | 86fac11d5aaac1aa9d0fef09b10aec062bb0eb63 (patch) | |
tree | e03018c868afbcc3a19faca5d4e1472428cf13d9 /llvm/test/CodeGen/X86/setcc-logic.ll | |
parent | 511092cab08819f832a4e3acd0547600a1c41eac (diff) | |
download | bcm5719-llvm-86fac11d5aaac1aa9d0fef09b10aec062bb0eb63.tar.gz bcm5719-llvm-86fac11d5aaac1aa9d0fef09b10aec062bb0eb63.zip |
[DAGCombiner] convert logic-of-setcc into bit magic (PR40611)
If we're comparing some value for equality against 2 constants
and those constants have an absolute difference of just 1 bit,
then we can offset and mask off that 1 bit and reduce to a single
compare against zero:
and/or (setcc X, C0, ne), (setcc X, C1, ne/eq) -->
setcc ((add X, -C1), ~(C0 - C1)), 0, ne/eq
https://rise4fun.com/Alive/XslKj
This transform is disabled by default using a TLI hook
("convertSetCCLogicToBitwiseLogic()").
That should be overridden for AArch64, MIPS, Sparc and possibly
others based on the asm shown in:
https://bugs.llvm.org/show_bug.cgi?id=40611
llvm-svn: 353859
Diffstat (limited to 'llvm/test/CodeGen/X86/setcc-logic.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/setcc-logic.ll | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/test/CodeGen/X86/setcc-logic.ll b/llvm/test/CodeGen/X86/setcc-logic.ll index f95ce9bfae2..46db9271d31 100644 --- a/llvm/test/CodeGen/X86/setcc-logic.ll +++ b/llvm/test/CodeGen/X86/setcc-logic.ll @@ -485,11 +485,9 @@ define <4 x i1> @and_eq_vec(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i32> define i1 @or_icmps_const_1bit_diff(i8 %x) { ; CHECK-LABEL: or_icmps_const_1bit_diff: ; CHECK: # %bb.0: -; CHECK-NEXT: cmpb $43, %dil -; CHECK-NEXT: sete %cl -; CHECK-NEXT: cmpb $45, %dil +; CHECK-NEXT: addb $-43, %dil +; CHECK-NEXT: testb $-3, %dil ; CHECK-NEXT: sete %al -; CHECK-NEXT: orb %cl, %al ; CHECK-NEXT: retq %a = icmp eq i8 %x, 43 %b = icmp eq i8 %x, 45 @@ -500,11 +498,9 @@ define i1 @or_icmps_const_1bit_diff(i8 %x) { define i1 @and_icmps_const_1bit_diff(i32 %x) { ; CHECK-LABEL: and_icmps_const_1bit_diff: ; CHECK: # %bb.0: -; CHECK-NEXT: cmpl $44, %edi -; CHECK-NEXT: setne %cl -; CHECK-NEXT: cmpl $60, %edi +; CHECK-NEXT: addl $-44, %edi +; CHECK-NEXT: testl $-17, %edi ; CHECK-NEXT: setne %al -; CHECK-NEXT: andb %cl, %al ; CHECK-NEXT: retq %a = icmp ne i32 %x, 44 %b = icmp ne i32 %x, 60 |