1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -p indvars -S -o - %s | FileCheck %s
4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
7 define void @test_s172(i32 noundef %xa, i32 noundef %xb, ptr nocapture noundef %a, ptr nocapture noundef readonly %b) {
8 ; CHECK-LABEL: define void @test_s172(
9 ; CHECK-SAME: i32 noundef [[XA:%.*]], i32 noundef [[XB:%.*]], ptr nocapture noundef [[A:%.*]], ptr nocapture noundef readonly [[B:%.*]]) {
11 ; CHECK-NEXT: [[SUB:%.*]] = add i32 [[XA]], -1
12 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[XA]], 32001
13 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
14 ; CHECK: for.body.preheader:
15 ; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[SUB]] to i64
16 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[XB]] to i64
17 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
19 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[TMP0]], [[FOR_BODY_PREHEADER]] ]
20 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[B]], i64 [[INDVARS_IV]]
21 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
22 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
23 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
24 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP3]], [[TMP2]]
25 ; CHECK-NEXT: store i32 [[ADD]], ptr [[ARRAYIDX2]], align 4
26 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], [[TMP1]]
27 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[INDVARS_IV_NEXT]], 32000
28 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop [[LOOP0:![0-9]+]]
29 ; CHECK: for.end.loopexit:
30 ; CHECK-NEXT: br label [[FOR_END]]
32 ; CHECK-NEXT: ret void
35 %sub = add nsw i32 %xa, -1
36 %cmp1 = icmp slt i32 %xa, 32001
37 br i1 %cmp1, label %for.body.preheader, label %for.end
43 %i.02 = phi i32 [ %add3, %for.body ], [ %sub, %for.body.preheader ]
44 %idxprom = sext i32 %i.02 to i64
45 %arrayidx = getelementptr inbounds i32, ptr %b, i64 %idxprom
46 %0 = load i32, ptr %arrayidx, align 4
47 %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %idxprom
48 %1 = load i32, ptr %arrayidx2, align 4
49 %add = add nsw i32 %1, %0
50 store i32 %add, ptr %arrayidx2, align 4
51 %add3 = add nsw i32 %i.02, %xb
52 %cmp = icmp slt i32 %add3, 32000
53 br i1 %cmp, label %for.body, label %for.end.loopexit, !llvm.loop !0
62 !0 = distinct !{!0, !1}
63 !1 = !{!"llvm.loop.mustprogress"}
65 ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]]}
66 ; CHECK: [[META1]] = !{!"llvm.loop.mustprogress"}