56 lines · plain
1; RUN: opt < %s -loop-reduce -lsr-setupcost-depth-limit=1 -S | FileCheck %s2 3; This test is adapted from the n-body test of the LLVM test-suite: A bug in4; r345114 caused LSR to generate incorrect code. The test verifies that the5; induction variable generated for the inner loop depends on the induction6; variable of the outer loop.7 8target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"9target triple = "x86_64-unknown-linux-gnu"10 11%struct.planet.0.3.6.11.12.15.16.17.24.25.26.33.44 = type { double, double, double, double, double, double, double }12 13; Function Attrs: nounwind uwtable14define dso_local void @advance(i32 %nbodies, ptr nocapture %bodies) local_unnamed_addr #0 {15; CHECK-LABEL: @advance(16; CHECK: for.cond.loopexit:17; CHECK: [[LSR_IV_NEXT:%.*]] = add i64 [[LSR_IV:%.*]], -118; CHECK: br label %for.body19; CHECK: for.body:20; CHECK: [[LSR_IV]] = phi i64 [ [[LSR_IV_NEXT]]21; CHECK: br label %for.body322; CHECK: for.body3:23; CHECK: [[LSR_IV1:%.*]] = phi i64 [ [[LSR_IV_NEXT2:%.*]], %for.body3 ], [ [[LSR_IV]], %for.body ]24; CHECK: [[LSR_IV_NEXT2]] = add i64 [[LSR_IV1]], -125; CHECK: [[EXITCOND:%.*]] = icmp eq i64 [[LSR_IV_NEXT2]], 026; CHECK: br i1 [[EXITCOND]], label %for.cond.loopexit, label %for.body327;28entry:29 %wide.trip.count = zext i32 %nbodies to i6430 br label %for.body31 32for.cond.loopexit: ; preds = %for.body333 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 134 br label %for.body35 36for.body: ; preds = %for.cond.loopexit, %entry37 %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.cond.loopexit ]38 br label %for.body339 40for.body3: ; preds = %for.body3, %for.body41 %indvars.iv98 = phi i64 [ %indvars.iv, %for.body ], [ %indvars.iv.next99, %for.body3 ]42 %z9 = getelementptr inbounds %struct.planet.0.3.6.11.12.15.16.17.24.25.26.33.44, ptr %bodies, i64 %indvars.iv98, i32 243 %tmp = load double, ptr %z9, align 8, !tbaa !044 %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 145 %exitcond = icmp eq i64 %indvars.iv.next99, %wide.trip.count46 br i1 %exitcond, label %for.cond.loopexit, label %for.body347}48 49attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }50 51!0 = !{!1, !2, i64 16}52!1 = !{!"planet", !2, i64 0, !2, i64 8, !2, i64 16, !2, i64 24, !2, i64 32, !2, i64 40, !2, i64 48}53!2 = !{!"double", !3, i64 0}54!3 = !{!"omnipotent char", !4, i64 0}55!4 = !{!"Simple C/C++ TBAA"}56