Skip to content

Commit

Permalink
[InstCombine] add tests for xor_of_icmps. nfc
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCBing committed Jul 13, 2022
1 parent 6b1d151 commit 97d1b48
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions llvm/test/Transforms/InstCombine/set.ll
Expand Up @@ -222,8 +222,8 @@ define i1 @xor_of_icmps_commute(i64 %a) {

; FIXME: This is (a != 5).

define i1 @xor_of_icmps_folds_more(i64 %a) {
; CHECK-LABEL: @xor_of_icmps_folds_more(
define i1 @xor_of_icmps_to_ne(i64 %a) {
; CHECK-LABEL: @xor_of_icmps_to_ne(
; CHECK-NEXT: [[B:%.*]] = icmp sgt i64 [[A:%.*]], 4
; CHECK-NEXT: [[C:%.*]] = icmp slt i64 [[A]], 6
; CHECK-NEXT: [[XOR:%.*]] = xor i1 [[B]], [[C]]
Expand All @@ -235,6 +235,43 @@ define i1 @xor_of_icmps_folds_more(i64 %a) {
ret i1 %xor
}

define i1 @xor_of_icmps_to_ne_commute(i64 %a) {
; CHECK-LABEL: @xor_of_icmps_to_ne_commute(
; CHECK-NEXT: [[C:%.*]] = icmp sgt i64 [[A:%.*]], 4
; CHECK-NEXT: [[B:%.*]] = icmp slt i64 [[A]], 6
; CHECK-NEXT: [[XOR:%.*]] = xor i1 [[B]], [[C]]
; CHECK-NEXT: ret i1 [[XOR]]
;
%c = icmp sgt i64 %a, 4
%b = icmp slt i64 %a, 6
%xor = xor i1 %b, %c
ret i1 %xor
}

define i1 @xor_of_icmps_neg_to_ne(i64 %a) {
; CHECK-LABEL: @xor_of_icmps_neg_to_ne(
; CHECK-NEXT: [[B:%.*]] = icmp sgt i64 [[A:%.*]], -6
; CHECK-NEXT: [[C:%.*]] = icmp slt i64 [[A]], -4
; CHECK-NEXT: [[XOR:%.*]] = xor i1 [[B]], [[C]]
; CHECK-NEXT: ret i1 [[XOR]]
;
%b = icmp sgt i64 %a, -6
%c = icmp slt i64 %a, -4
%xor = xor i1 %b, %c
ret i1 %xor
}

define i1 @xor_of_icmps_to_eq(i8 %a) {
; CHECK-LABEL: @xor_of_icmps_to_eq(
; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[A:%.*]], 127
; CHECK-NEXT: ret i1 [[C]]
;
%c = icmp sgt i8 %a, 126
%b = icmp slt i8 %a, 128
%xor = xor i1 %b, %c
ret i1 %xor
}

; https://bugs.llvm.org/show_bug.cgi?id=2844

define i32 @PR2844(i32 %x) {
Expand Down

0 comments on commit 97d1b48

Please sign in to comment.