Skip to content

Commit 81ac23e

Browse files
committed
[InstCombine] Add additional tests for foldAndOrOfICmpEqZeroAndICmp (NFC)
Adds logical variants of the commuted tests.
1 parent 67819a7 commit 81ac23e

File tree

1 file changed

+25
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+25
-0
lines changed

llvm/test/Transforms/InstCombine/icmp.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,31 @@ define i1 @and_icmp_ne_B_0_icmp_uge_A_B_commuted2(i64 %a, i64 %b) {
22922292
ret i1 %3
22932293
}
22942294

2295+
define i1 @and_icmp_ne_B_0_icmp_uge_A_B_commuted1_logical(i64 %a, i64 %b) {
2296+
; CHECK-LABEL: @and_icmp_ne_B_0_icmp_uge_A_B_commuted1_logical(
2297+
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[B:%.*]], -1
2298+
; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i64 [[TMP1]], [[A:%.*]]
2299+
; CHECK-NEXT: ret i1 [[TMP2]]
2300+
;
2301+
%1 = icmp uge i64 %a, %b
2302+
%2 = icmp ne i64 %b, 0
2303+
%3 = select i1 %1, i1 %2, i1 false
2304+
ret i1 %3
2305+
}
2306+
2307+
define i1 @and_icmp_ne_B_0_icmp_uge_A_B_commuted2_logical(i64 %a, i64 %b) {
2308+
; CHECK-LABEL: @and_icmp_ne_B_0_icmp_uge_A_B_commuted2_logical(
2309+
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[B:%.*]], 0
2310+
; CHECK-NEXT: [[TMP2:%.*]] = icmp ule i64 [[B]], [[A:%.*]]
2311+
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i1 [[TMP2]], i1 false
2312+
; CHECK-NEXT: ret i1 [[TMP3]]
2313+
;
2314+
%1 = icmp ne i64 %b, 0
2315+
%2 = icmp ule i64 %b, %a
2316+
%3 = select i1 %1, i1 %2, i1 false
2317+
ret i1 %3
2318+
}
2319+
22952320
define i1 @and_icmp_ne_B_0_icmp_uge_A_B_extra_use1(i64 %a, i64 %b) {
22962321
; CHECK-LABEL: @and_icmp_ne_B_0_icmp_uge_A_B_extra_use1(
22972322
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[B:%.*]], 0

0 commit comments

Comments
 (0)