[llvm] r353855 - [x86] add negative tests for setcc folds; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 12 08:44:37 PST 2019
Author: spatel
Date: Tue Feb 12 08:44:37 2019
New Revision: 353855
URL: http://llvm.org/viewvc/llvm-project?rev=353855&view=rev
Log:
[x86] add negative tests for setcc folds; NFC
Modified:
llvm/trunk/test/CodeGen/X86/setcc-logic.ll
Modified: llvm/trunk/test/CodeGen/X86/setcc-logic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/setcc-logic.ll?rev=353855&r1=353854&r2=353855&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/setcc-logic.ll (original)
+++ llvm/trunk/test/CodeGen/X86/setcc-logic.ll Tue Feb 12 08:44:37 2019
@@ -512,3 +512,73 @@ define i1 @and_icmps_const_1bit_diff(i32
ret i1 %r
}
+; Negative test - extra use prevents optimization
+
+define i1 @or_icmps_const_1bit_diff_extra_use(i8 %x, i8* %p) {
+; CHECK-LABEL: or_icmps_const_1bit_diff_extra_use:
+; CHECK: # %bb.0:
+; CHECK-NEXT: cmpb $45, %dil
+; CHECK-NEXT: sete %cl
+; CHECK-NEXT: cmpb $43, %dil
+; CHECK-NEXT: sete %al
+; CHECK-NEXT: sete (%rsi)
+; CHECK-NEXT: orb %cl, %al
+; CHECK-NEXT: retq
+ %a = icmp eq i8 %x, 43
+ %b = icmp eq i8 %x, 45
+ %r = or i1 %a, %b
+ %z = zext i1 %a to i8
+ store i8 %z, i8* %p
+ ret i1 %r
+}
+
+; Negative test - constant diff is >1 bit
+
+define i1 @and_icmps_const_not1bit_diff(i32 %x) {
+; CHECK-LABEL: and_icmps_const_not1bit_diff:
+; CHECK: # %bb.0:
+; CHECK-NEXT: cmpl $44, %edi
+; CHECK-NEXT: setne %cl
+; CHECK-NEXT: cmpl $92, %edi
+; CHECK-NEXT: setne %al
+; CHECK-NEXT: andb %cl, %al
+; CHECK-NEXT: retq
+ %a = icmp ne i32 %x, 44
+ %b = icmp ne i32 %x, 92
+ %r = and i1 %a, %b
+ ret i1 %r
+}
+
+; Negative test - wrong comparison
+
+define i1 @and_icmps_const_1bit_diff_wrong_pred(i32 %x) {
+; CHECK-LABEL: and_icmps_const_1bit_diff_wrong_pred:
+; CHECK: # %bb.0:
+; CHECK-NEXT: cmpl $43, %edi
+; CHECK-NEXT: sete %cl
+; CHECK-NEXT: cmpl $45, %edi
+; CHECK-NEXT: setl %al
+; CHECK-NEXT: orb %cl, %al
+; CHECK-NEXT: retq
+ %a = icmp eq i32 %x, 43
+ %b = icmp slt i32 %x, 45
+ %r = or i1 %a, %b
+ ret i1 %r
+}
+
+; Negative test - no common operand
+
+define i1 @and_icmps_const_1bit_diff_common_op(i32 %x, i32 %y) {
+; CHECK-LABEL: and_icmps_const_1bit_diff_common_op:
+; CHECK: # %bb.0:
+; CHECK-NEXT: cmpl $43, %edi
+; CHECK-NEXT: sete %cl
+; CHECK-NEXT: cmpl $45, %esi
+; CHECK-NEXT: sete %al
+; CHECK-NEXT: orb %cl, %al
+; CHECK-NEXT: retq
+ %a = icmp eq i32 %x, 43
+ %b = icmp eq i32 %y, 45
+ %r = or i1 %a, %b
+ ret i1 %r
+}
More information about the llvm-commits
mailing list