1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt "-passes=loop-rotate,indvars" -S < %s | FileCheck %s
3 ; RUN: opt "-passes=loop-rotate" < %s | opt "-passes=indvars" -S - | FileCheck %s
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6 target triple = "aarch64-unknown-linux-gnu"
8 define dso_local float @foo(ptr noalias %dst, ptr %src, i32 %offset, i32 %N) {
11 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 1, [[N:%.*]]
12 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_COND_CLEANUP:%.*]]
13 ; CHECK: for.body.lr.ph:
14 ; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[OFFSET:%.*]] to i64
15 ; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[N]] to i64
16 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
17 ; CHECK: for.cond.for.cond.cleanup_crit_edge:
18 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
19 ; CHECK: for.cond.cleanup:
20 ; CHECK-NEXT: ret float undef
22 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
23 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw i64 [[INDVARS_IV]], [[TMP0]]
24 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[SRC:%.*]], i64 [[TMP1]]
25 ; CHECK-NEXT: [[TMP2:%.*]] = load float, ptr [[ARRAYIDX]], align 4
26 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw i64 [[TMP1]], 1
27 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds float, ptr [[SRC]], i64 [[TMP3]]
28 ; CHECK-NEXT: [[TMP4:%.*]] = load float, ptr [[ARRAYIDX3]], align 4
29 ; CHECK-NEXT: [[ADD4:%.*]] = fadd fast float [[TMP2]], [[TMP4]]
30 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds float, ptr [[DST:%.*]], i64 [[INDVARS_IV]]
31 ; CHECK-NEXT: store float [[ADD4]], ptr [[ARRAYIDX6]], align 4
32 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
33 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
34 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_COND_FOR_COND_CLEANUP_CRIT_EDGE:%.*]], !llvm.loop [[LOOP0:![0-9]+]]
39 for.cond: ; preds = %for.body, %entry
40 %i.0 = phi i32 [ 1, %entry ], [ %inc, %for.body ]
41 %cmp = icmp slt i32 %i.0, %N
42 br i1 %cmp, label %for.body, label %for.cond.cleanup
44 for.cond.cleanup: ; preds = %for.cond
47 for.body: ; preds = %for.cond
48 %add = add nsw i32 %i.0, %offset
49 %idxprom = sext i32 %add to i64
50 %arrayidx = getelementptr inbounds float, ptr %src, i64 %idxprom
51 %0 = load float, ptr %arrayidx, align 4
52 %add1 = add nsw i32 %add, 1
53 %idxprom2 = sext i32 %add1 to i64
54 %arrayidx3 = getelementptr inbounds float, ptr %src, i64 %idxprom2
55 %1 = load float, ptr %arrayidx3, align 4
56 %add4 = fadd fast float %0, %1
57 %idxprom5 = zext i32 %i.0 to i64
58 %arrayidx6 = getelementptr inbounds float, ptr %dst, i64 %idxprom5
59 store float %add4, ptr %arrayidx6, align 4
60 %inc = add nuw nsw i32 %i.0, 1
61 br label %for.cond, !llvm.loop !1
64 !1 = distinct !{!1, !2}
65 !2 = !{!"llvm.loop.mustprogress"}