Skip to content

Commit 1657331

Browse files
committed
[InstCombine] Test for fold of and of icmps with operands in the range(0,2) (NFC)
proof https://alive2.llvm.org/ce/z/xeazCu this is a regression found in #128861 This fold is done when icmp eq/ne x, 1/0 is folded to trunc nuw x iff x is in the range(0,2)
1 parent 008e3a0 commit 1657331

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

llvm/test/Transforms/InstCombine/and-or-icmps.ll

+28
Original file line numberDiff line numberDiff line change
@@ -3409,3 +3409,31 @@ define i1 @and_ugt_to_mask_off_by_one(i8 %x) {
34093409
%and2 = and i1 %cmp, %cmp2
34103410
ret i1 %and2
34113411
}
3412+
3413+
; TODO: shall fold to trunc nuw i8 (and %x, %y) to i1.
3414+
define i1 @and_icmp_ne_with_binary_range_operands(i8 range(i8 0, 2) %x, i8 range(i8 0, 2) %y) {
3415+
; CHECK-LABEL: @and_icmp_ne_with_binary_range_operands(
3416+
; CHECK-NEXT: [[ICMP1:%.*]] = icmp ne i8 [[X:%.*]], 0
3417+
; CHECK-NEXT: [[ICMP2:%.*]] = icmp ne i8 [[Y:%.*]], 0
3418+
; CHECK-NEXT: [[RET:%.*]] = and i1 [[ICMP1]], [[ICMP2]]
3419+
; CHECK-NEXT: ret i1 [[RET]]
3420+
;
3421+
%icmp1 = icmp ne i8 %x, 0
3422+
%icmp2 = icmp ne i8 %y, 0
3423+
%ret = and i1 %icmp1, %icmp2
3424+
ret i1 %ret
3425+
}
3426+
3427+
; TODO: shall fold to trunc nuw i8 (and %x, %y) to i1.
3428+
define i1 @and_icmp_eq_with_binary_range_operands(i8 range(i8 0, 2) %x, i8 range(i8 0, 2) %y) {
3429+
; CHECK-LABEL: @and_icmp_eq_with_binary_range_operands(
3430+
; CHECK-NEXT: [[ICMP1:%.*]] = icmp ne i8 [[X:%.*]], 0
3431+
; CHECK-NEXT: [[ICMP2:%.*]] = icmp ne i8 [[Y:%.*]], 0
3432+
; CHECK-NEXT: [[RET:%.*]] = and i1 [[ICMP1]], [[ICMP2]]
3433+
; CHECK-NEXT: ret i1 [[RET]]
3434+
;
3435+
%icmp1 = icmp eq i8 %x, 1
3436+
%icmp2 = icmp eq i8 %y, 1
3437+
%ret = and i1 %icmp1, %icmp2
3438+
ret i1 %ret
3439+
}

0 commit comments

Comments
 (0)