1 ; RUN: opt < %s -S -loop-unroll -unroll-threshold=50 | FileCheck %s 2 3 ; Make sure this loop is completely unrolled... 4 ; CHECK-LABEL: @test1 5 ; CHECK: for.body: 6 ; CHECK-NOT: for.end: 7 8 define i32 @test1(i32* nocapture %a) nounwind uwtable readonly { 9 entry: 10 br label %for.body 11 12 for.body: ; preds = %for.body, %entry 13 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 14 %sum.01 = phi i32 [ 0, %entry ], [ %add, %for.body ] 15 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv 16 %0 = load i32, i32* %arrayidx, align 4 17 18 ; This loop will be completely unrolled, even with these extra instructions, 19 ; but only because they're ephemeral (and, thus, free). 20 %1 = add nsw i32 %0, 2 21 %2 = add nsw i32 %1, 4 22 %3 = add nsw i32 %2, 4 23 %4 = add nsw i32 %3, 4 24 %5 = add nsw i32 %4, 4 25 %6 = add nsw i32 %5, 4 26 %7 = add nsw i32 %6, 4 27 %8 = add nsw i32 %7, 4 28 %9 = add nsw i32 %8, 4 29 %10 = add nsw i32 %9, 4 30 %ca = icmp sgt i32 %10, -7 31 call void @llvm.assume(i1 %ca) 32 33 %add = add nsw i32 %0, %sum.01 34 %indvars.iv.next = add i64 %indvars.iv, 1 35 %lftr.wideiv = trunc i64 %indvars.iv.next to i32 36 %exitcond = icmp eq i32 %lftr.wideiv, 5 37 br i1 %exitcond, label %for.end, label %for.body 38 39 for.end: ; preds = %for.body 40 ret i32 %add 41 } 42 43 declare void @llvm.assume(i1) nounwind 44 45