[x86] add negative tests for setcc folds; NFC

llvm-svn: 353855
This commit is contained in:
Sanjay Patel 2019-02-12 16:44:37 +00:00
parent 77ccc2eba4
commit ab7e26a2de

View File

@ -512,3 +512,73 @@ define i1 @and_icmps_const_1bit_diff(i32 %x) {
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
}