Skip to content

Commit

Permalink
[InstCombine] Add additional tests for foldAndOrOfICmpEqZeroAndICmp (…
Browse files Browse the repository at this point in the history
…NFC)

Adds logical variants of the commuted tests.
  • Loading branch information
nikic committed Dec 13, 2022
1 parent 67819a7 commit 81ac23e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions llvm/test/Transforms/InstCombine/icmp.ll
Expand Up @@ -2292,6 +2292,31 @@ define i1 @and_icmp_ne_B_0_icmp_uge_A_B_commuted2(i64 %a, i64 %b) {
ret i1 %3
}

define i1 @and_icmp_ne_B_0_icmp_uge_A_B_commuted1_logical(i64 %a, i64 %b) {
; CHECK-LABEL: @and_icmp_ne_B_0_icmp_uge_A_B_commuted1_logical(
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[B:%.*]], -1
; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i64 [[TMP1]], [[A:%.*]]
; CHECK-NEXT: ret i1 [[TMP2]]
;
%1 = icmp uge i64 %a, %b
%2 = icmp ne i64 %b, 0
%3 = select i1 %1, i1 %2, i1 false
ret i1 %3
}

define i1 @and_icmp_ne_B_0_icmp_uge_A_B_commuted2_logical(i64 %a, i64 %b) {
; CHECK-LABEL: @and_icmp_ne_B_0_icmp_uge_A_B_commuted2_logical(
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[B:%.*]], 0
; CHECK-NEXT: [[TMP2:%.*]] = icmp ule i64 [[B]], [[A:%.*]]
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i1 [[TMP2]], i1 false
; CHECK-NEXT: ret i1 [[TMP3]]
;
%1 = icmp ne i64 %b, 0
%2 = icmp ule i64 %b, %a
%3 = select i1 %1, i1 %2, i1 false
ret i1 %3
}

define i1 @and_icmp_ne_B_0_icmp_uge_A_B_extra_use1(i64 %a, i64 %b) {
; CHECK-LABEL: @and_icmp_ne_B_0_icmp_uge_A_B_extra_use1(
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[B:%.*]], 0
Expand Down

0 comments on commit 81ac23e

Please sign in to comment.