1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -indvars < %s | FileCheck %s
4 ; Provide legal integer types.
5 target datalayout = "n8:16:32:64"
8 define void @test1(float* nocapture %autoc, float* nocapture %data, float %d, i32 %data_len, i32 %sample) nounwind {
11 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[DATA_LEN:%.*]], [[SAMPLE:%.*]]
12 ; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i32 [[DATA_LEN]], [[SAMPLE]]
13 ; CHECK-NEXT: br i1 [[CMP4]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
14 ; CHECK: for.body.preheader:
15 ; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[SUB]] to i64
16 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
18 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
19 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[INDVARS_IV]] to i32
20 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP0]], [[SAMPLE]]
21 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[ADD]] to i64
22 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[DATA:%.*]], i64 [[IDXPROM]]
23 ; CHECK-NEXT: [[TMP1:%.*]] = load float, float* [[ARRAYIDX]], align 4
24 ; CHECK-NEXT: [[MUL:%.*]] = fmul float [[TMP1]], [[D:%.*]]
25 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds float, float* [[AUTOC:%.*]], i64 [[INDVARS_IV]]
26 ; CHECK-NEXT: [[TMP2:%.*]] = load float, float* [[ARRAYIDX2]], align 4
27 ; CHECK-NEXT: [[ADD3:%.*]] = fadd float [[TMP2]], [[MUL]]
28 ; CHECK-NEXT: store float [[ADD3]], float* [[ARRAYIDX2]], align 4
29 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
30 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
31 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
32 ; CHECK: for.end.loopexit:
33 ; CHECK-NEXT: br label [[FOR_END]]
35 ; CHECK-NEXT: ret void
38 %sub = sub i32 %data_len, %sample
39 %cmp4 = icmp eq i32 %data_len, %sample
40 br i1 %cmp4, label %for.end, label %for.body
42 for.body: ; preds = %entry, %for.body
43 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
44 %0 = trunc i64 %indvars.iv to i32
45 %add = add i32 %0, %sample
46 %idxprom = zext i32 %add to i64
47 %arrayidx = getelementptr inbounds float, float* %data, i64 %idxprom
48 %1 = load float, float* %arrayidx, align 4
49 %mul = fmul float %1, %d
50 %arrayidx2 = getelementptr inbounds float, float* %autoc, i64 %indvars.iv
51 %2 = load float, float* %arrayidx2, align 4
52 %add3 = fadd float %2, %mul
53 store float %add3, float* %arrayidx2, align 4
54 %indvars.iv.next = add i64 %indvars.iv, 1
55 %3 = trunc i64 %indvars.iv.next to i32
56 %cmp = icmp ult i32 %3, %sub
57 br i1 %cmp, label %for.body, label %for.end
59 for.end: ; preds = %for.body, %entry
63 ; check that we turn the IV test into an eq.