1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' < %s | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
5 target triple = "thumbv8.1m.main-none-eabi"
7 define i32 @lshr3_then(i32 %a) {
8 ; CHECK-LABEL: @lshr3_then(
10 ; CHECK-NEXT: [[L:%.*]] = lshr i32 [[A:%.*]], 3
11 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
12 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
14 ; CHECK-NEXT: ret i32 0
16 ; CHECK-NEXT: ret i32 [[L]]
19 %c = icmp ult i32 %a, 8
20 br i1 %c, label %then, label %else
30 define i32 @lshr5_else(i32 %a) {
31 ; CHECK-LABEL: @lshr5_else(
33 ; CHECK-NEXT: [[L:%.*]] = lshr i32 [[A:%.*]], 5
34 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
35 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
37 ; CHECK-NEXT: ret i32 [[L]]
39 ; CHECK-NEXT: ret i32 0
42 %c = icmp ult i32 %a, 32
43 br i1 %c, label %then, label %else
53 define i32 @lshr2_entry(i32 %a) {
54 ; CHECK-LABEL: @lshr2_entry(
56 ; CHECK-NEXT: [[L:%.*]] = lshr i32 [[A:%.*]], 1
57 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
58 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
60 ; CHECK-NEXT: ret i32 [[L]]
62 ; CHECK-NEXT: ret i32 0
66 %c = icmp ult i32 %a, 2
67 br i1 %c, label %then, label %else
76 define i32 @lshr5mismatch(i32 %a) {
77 ; CHECK-LABEL: @lshr5mismatch(
79 ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A:%.*]], 17
80 ; CHECK-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[ELSE:%.*]]
82 ; CHECK-NEXT: [[L:%.*]] = lshr i32 [[A]], 5
83 ; CHECK-NEXT: ret i32 [[L]]
85 ; CHECK-NEXT: ret i32 0
88 %c = icmp ult i32 %a, 17
89 br i1 %c, label %then, label %else
99 define i32 @ashr5_else(i32 %a) {
100 ; CHECK-LABEL: @ashr5_else(
102 ; CHECK-NEXT: [[L:%.*]] = ashr i32 [[A:%.*]], 5
103 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
104 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
106 ; CHECK-NEXT: ret i32 [[L]]
108 ; CHECK-NEXT: ret i32 0
111 %c = icmp ult i32 %a, 32
112 br i1 %c, label %then, label %else
122 define i32 @add10_else(i32 %a) {
123 ; CHECK-LABEL: @add10_else(
125 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[A:%.*]], 10
126 ; CHECK-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[ELSE:%.*]]
128 ; CHECK-NEXT: ret i32 0
130 ; CHECK-NEXT: [[L:%.*]] = add i32 [[A]], 10
131 ; CHECK-NEXT: ret i32 [[L]]
134 %c = icmp eq i32 %a, 10
135 br i1 %c, label %then, label %else
145 define i32 @addm10_then(i32 %a) {
146 ; CHECK-LABEL: @addm10_then(
148 ; CHECK-NEXT: [[L:%.*]] = add i32 [[A:%.*]], -10
149 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
150 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
152 ; CHECK-NEXT: ret i32 [[L]]
154 ; CHECK-NEXT: ret i32 0
157 %c = icmp eq i32 %a, 10
158 br i1 %c, label %then, label %else
168 define i32 @add_missmatch(i32 %a) {
169 ; CHECK-LABEL: @add_missmatch(
171 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[A:%.*]], 10
172 ; CHECK-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[ELSE:%.*]]
174 ; CHECK-NEXT: [[L:%.*]] = add i32 [[A]], 10
175 ; CHECK-NEXT: ret i32 [[L]]
177 ; CHECK-NEXT: ret i32 0
180 %c = icmp eq i32 %a, 10
181 br i1 %c, label %then, label %else
191 define i32 @sub10_else(i32 %a) {
192 ; CHECK-LABEL: @sub10_else(
194 ; CHECK-NEXT: [[L:%.*]] = sub i32 [[A:%.*]], 10
195 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
196 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
198 ; CHECK-NEXT: ret i32 0
200 ; CHECK-NEXT: ret i32 [[L]]
203 %c = icmp eq i32 %a, 10
204 br i1 %c, label %then, label %else
214 define i32 @sub10_else_drop_nuw(i32 %a) {
215 ; CHECK-LABEL: @sub10_else_drop_nuw(
217 ; CHECK-NEXT: [[L:%.*]] = sub i32 [[A:%.*]], 10
218 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
219 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
221 ; CHECK-NEXT: ret i32 0
223 ; CHECK-NEXT: ret i32 [[L]]
226 %c = icmp eq i32 %a, 10
227 br i1 %c, label %then, label %else
233 %l = sub nuw i32 %a, 10
237 define i32 @subm10_then(i32 %a) {
238 ; CHECK-LABEL: @subm10_then(
240 ; CHECK-NEXT: [[L:%.*]] = sub i32 [[A:%.*]], -10
241 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[L]], 0
242 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
244 ; CHECK-NEXT: ret i32 [[L]]
246 ; CHECK-NEXT: ret i32 0
249 %c = icmp eq i32 %a, -10
250 br i1 %c, label %then, label %else
260 define i64 @lshr64(i64 %a) {
261 ; CHECK-LABEL: @lshr64(
263 ; CHECK-NEXT: [[L:%.*]] = lshr i64 [[A:%.*]], 40
264 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i64 [[L]], 0
265 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
267 ; CHECK-NEXT: ret i64 0
269 ; CHECK-NEXT: ret i64 [[L]]
272 %c = icmp ult i64 %a, 1099511627776
273 br i1 %c, label %then, label %else
283 define i128 @lshr128(i128 %a) {
284 ; CHECK-LABEL: @lshr128(
286 ; CHECK-NEXT: [[L:%.*]] = lshr i128 [[A:%.*]], 65
287 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i128 [[L]], 0
288 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN:%.*]], label [[ELSE:%.*]]
290 ; CHECK-NEXT: ret i128 0
292 ; CHECK-NEXT: ret i128 [[L]]
295 %c = icmp ult i128 %a, 36893488147419103232
296 br i1 %c, label %then, label %else
302 %l = lshr i128 %a, 65
306 define i32 @addm1_dom(i32 %a) {
307 ; CHECK-LABEL: @addm1_dom(
309 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i32 [[A:%.*]], 100
310 ; CHECK-NEXT: br i1 [[C1]], label [[IF:%.*]], label [[ELSE:%.*]]
312 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[A]], -1
313 ; CHECK-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[ELSE]]
315 ; CHECK-NEXT: ret i32 0
317 ; CHECK-NEXT: [[L:%.*]] = add i32 [[A]], 1
318 ; CHECK-NEXT: ret i32 [[L]]
321 %c1 = icmp eq i32 %a, 100
322 br i1 %c1, label %if, label %else
325 %c = icmp eq i32 %a, -1
326 br i1 %c, label %then, label %else
336 declare void @other()