1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s
4 define i8 @test0(i8 %a) {
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 3
8 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
10 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i8 [[A]], 50
11 ; CHECK-NEXT: ret i8 [[MUL]]
13 ; CHECK-NEXT: ret i8 0
16 %cmp = icmp ult i8 %a, 3
17 br i1 %cmp, label %bb, label %exit
27 define i8 @test1(i8 %a) {
28 ; CHECK-LABEL: @test1(
30 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 4
31 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
33 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[A]], 50
34 ; CHECK-NEXT: ret i8 [[MUL]]
36 ; CHECK-NEXT: ret i8 0
39 %cmp = icmp ult i8 %a, 4
40 br i1 %cmp, label %bb, label %exit
50 define i8 @test2(i8 %a) {
51 ; CHECK-LABEL: @test2(
53 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 6
54 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
56 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[A]], 50
57 ; CHECK-NEXT: ret i8 [[MUL]]
59 ; CHECK-NEXT: ret i8 0
62 %cmp = icmp ult i8 %a, 6
63 br i1 %cmp, label %bb, label %exit
73 define i8 @test3(i8 %a) {
74 ; CHECK-LABEL: @test3(
76 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 7
77 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
79 ; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50
80 ; CHECK-NEXT: ret i8 [[MUL]]
82 ; CHECK-NEXT: ret i8 0
85 %cmp = icmp ult i8 %a, 7
86 br i1 %cmp, label %bb, label %exit
96 define i8 @test4(i8 %a) {
97 ; CHECK-LABEL: @test4(
99 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 [[A:%.*]], 3
100 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 [[A]], -3
101 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[CMP1]], [[CMP2]]
102 ; CHECK-NEXT: br i1 [[COND]], label [[BB:%.*]], label [[EXIT:%.*]]
104 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i8 [[A]], 50
105 ; CHECK-NEXT: ret i8 [[MUL]]
107 ; CHECK-NEXT: ret i8 0
110 %cmp1 = icmp slt i8 %a, 3
111 %cmp2 = icmp sgt i8 %a, -3
112 %cond = and i1 %cmp1, %cmp2
113 br i1 %cond, label %bb, label %exit
123 define i8 @test5(i8 %a) {
124 ; CHECK-LABEL: @test5(
126 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 [[A:%.*]], 3
127 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 [[A]], -4
128 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[CMP1]], [[CMP2]]
129 ; CHECK-NEXT: br i1 [[COND]], label [[BB:%.*]], label [[EXIT:%.*]]
131 ; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50
132 ; CHECK-NEXT: ret i8 [[MUL]]
134 ; CHECK-NEXT: ret i8 0
137 %cmp1 = icmp slt i8 %a, 3
138 %cmp2 = icmp sgt i8 %a, -4
139 %cond = and i1 %cmp1, %cmp2
140 br i1 %cond, label %bb, label %exit
150 define i8 @test6(i8 %a) {
151 ; CHECK-LABEL: @test6(
153 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 [[A:%.*]], 4
154 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 [[A]], -3
155 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[CMP1]], [[CMP2]]
156 ; CHECK-NEXT: br i1 [[COND]], label [[BB:%.*]], label [[EXIT:%.*]]
158 ; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50
159 ; CHECK-NEXT: ret i8 [[MUL]]
161 ; CHECK-NEXT: ret i8 0
164 %cmp1 = icmp slt i8 %a, 4
165 %cmp2 = icmp sgt i8 %a, -3
166 %cond = and i1 %cmp1, %cmp2
167 br i1 %cond, label %bb, label %exit
177 define i1 @nuw_range1(i8 %b) {
178 ; CHECK-LABEL: @nuw_range1(
180 ; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], 1
181 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[C]], 4
182 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[MUL]], 0
183 ; CHECK-NEXT: ret i1 [[CMP]]
186 %c = add nuw nsw i8 %b, 1
187 %mul = mul nuw i8 %c, 4
188 %cmp = icmp eq i8 %mul, 0
192 define i1 @nuw_range2(i8 %b) {
193 ; CHECK-LABEL: @nuw_range2(
195 ; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], 3
196 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[C]], 4
197 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[MUL]], 2
198 ; CHECK-NEXT: ret i1 [[CMP]]
201 %c = add nuw nsw i8 %b, 3
202 %mul = mul nuw i8 %c, 4
203 %cmp = icmp ult i8 %mul, 2
207 define i1 @nsw_range1(i8 %b) {
208 ; CHECK-LABEL: @nsw_range1(
210 ; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], -3
211 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i8 [[C]], 4
212 ; CHECK-NEXT: ret i1 false
215 %c = add nuw nsw i8 %b, -3
216 %mul = mul nsw i8 %c, 4
217 %cmp = icmp slt i8 %c, %mul
221 define i1 @one_bit(i1 %a, i1 %b) {
222 ; CHECK-LABEL: @one_bit(
223 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i1 [[A:%.*]], [[B:%.*]]
224 ; CHECK-NEXT: ret i1 [[MUL]]