1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -passes=correlated-propagation < %s | FileCheck %s
6 define void @test_icmp_from_implied_cond(i32 %a, i32 %b) {
7 ; CHECK-LABEL: define void @test_icmp_from_implied_cond(
8 ; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {
9 ; CHECK-NEXT: [[A_CMP:%.*]] = icmp ugt i32 [[A]], 32
10 ; CHECK-NEXT: br i1 [[A_CMP]], label [[END:%.*]], label [[L1:%.*]]
12 ; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[B]], [[A]]
13 ; CHECK-NEXT: br i1 [[COND]], label [[L2:%.*]], label [[END]]
15 ; CHECK-NEXT: call void @use(i1 true)
16 ; CHECK-NEXT: [[B_CMP2:%.*]] = icmp samesign ult i32 [[B]], 31
17 ; CHECK-NEXT: call void @use(i1 [[B_CMP2]])
18 ; CHECK-NEXT: ret void
20 ; CHECK-NEXT: ret void
22 %a.cmp = icmp ugt i32 %a, 32
23 br i1 %a.cmp, label %end, label %l1
26 %cond = icmp ult i32 %b, %a
27 br i1 %cond, label %l2, label %end
30 %b.cmp1 = icmp ult i32 %b, 32
31 call void @use(i1 %b.cmp1)
32 %b.cmp2 = icmp ult i32 %b, 31
33 call void @use(i1 %b.cmp2)
40 define i64 @test_sext_from_implied_cond(i32 %a, i32 %b) {
41 ; CHECK-LABEL: define range(i64 0, 2147483647) i64 @test_sext_from_implied_cond(
42 ; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {
43 ; CHECK-NEXT: [[A_CMP:%.*]] = icmp slt i32 [[A]], 0
44 ; CHECK-NEXT: br i1 [[A_CMP]], label [[END:%.*]], label [[L1:%.*]]
46 ; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[B]], [[A]]
47 ; CHECK-NEXT: br i1 [[COND]], label [[L2:%.*]], label [[END]]
49 ; CHECK-NEXT: [[SEXT:%.*]] = zext nneg i32 [[B]] to i64
50 ; CHECK-NEXT: ret i64 [[SEXT]]
52 ; CHECK-NEXT: ret i64 0
54 %a.cmp = icmp slt i32 %a, 0
55 br i1 %a.cmp, label %end, label %l1
58 %cond = icmp ult i32 %b, %a
59 br i1 %cond, label %l2, label %end
62 %sext = sext i32 %b to i64
69 define void @test_icmp_from_implied_range(i16 %x, i32 %b) {
70 ; CHECK-LABEL: define void @test_icmp_from_implied_range(
71 ; CHECK-SAME: i16 [[X:%.*]], i32 [[B:%.*]]) {
72 ; CHECK-NEXT: [[A:%.*]] = zext i16 [[X]] to i32
73 ; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[B]], [[A]]
74 ; CHECK-NEXT: br i1 [[COND]], label [[L1:%.*]], label [[END:%.*]]
76 ; CHECK-NEXT: call void @use(i1 true)
77 ; CHECK-NEXT: [[B_CMP2:%.*]] = icmp samesign ult i32 [[B]], 65534
78 ; CHECK-NEXT: call void @use(i1 [[B_CMP2]])
79 ; CHECK-NEXT: ret void
81 ; CHECK-NEXT: ret void
83 %a = zext i16 %x to i32
84 %cond = icmp ult i32 %b, %a
85 br i1 %cond, label %l1, label %end
88 %b.cmp1 = icmp ult i32 %b, 65535
89 call void @use(i1 %b.cmp1)
90 %b.cmp2 = icmp ult i32 %b, 65534
91 call void @use(i1 %b.cmp2)