STATISTIC(NumUnrolled, "Number of loops unrolled (completely or otherwise)");
static cl::opt<bool>
-UnrollRuntimeEpilog("unroll-runtime-epilog", cl::init(true), cl::Hidden,
+UnrollRuntimeEpilog("unroll-runtime-epilog", cl::init(false), cl::Hidden,
cl::desc("Allow runtime unrolled loops to be unrolled "
"with epilog instead of prolog."));
-; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-a57 | FileCheck %s -check-prefix=EPILOG
+; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-a57 -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-a57 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
; Tests for unrolling loops with run-time trip counts
-; RUN: opt < %s -S -loop-unroll -unroll-runtime=true | FileCheck %s -check-prefix=EPILOG
+; RUN: opt < %s -S -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
; RUN: opt < %s -S -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 | FileCheck %s -check-prefix=EPILOG
+; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
; This tests that setting the unroll count works
-; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-count=8 | FileCheck %s -check-prefix=EPILOG
+; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-runtime-epilog=true -unroll-count=8 | FileCheck %s -check-prefix=EPILOG
; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
; Choose a smaller, power-of-two, unroll count if the loop is too large.
-; RUN: opt < %s -S -O2 -unroll-runtime=true | FileCheck %s -check-prefix=EPILOG
+; RUN: opt < %s -S -O2 -unroll-runtime=true -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
; RUN: opt < %s -S -O2 -unroll-runtime=true -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
; Check runtime unrolling prologue can be promoted by LICM pass.
%cmp1 = icmp eq i3 %n, 0
br i1 %cmp1, label %for.end, label %for.body
+; UNROLL-16-NOT: for.body.prol:
+; UNROLL-4: for.body.prol:
+
for.body: ; preds = %for.body, %entry
; UNROLL-16-LABEL: for.body:
; UNROLL-4-LABEL: for.body:
; UNROLL-16-LABEL: for.end
; UNROLL-4-LABEL: for.end
-
-; UNROLL-16-NOT: for.body.epil:
-; UNROLL-4: for.body.epil:
-
for.end: ; preds = %for.body, %entry
%sum.0.lcssa = phi i3 [ 0, %entry ], [ %add, %for.body ]
ret i3 %sum.0.lcssa
-; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll | FileCheck %s -check-prefix=EPILOG
+; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
; RUN: opt < %s -O2 -S | FileCheck %s
; After loop unroll:
-; %niter.nsub = add nsw i32 %niter, -1
+; %dec18 = add nsw i32 %dec18.in, -1
; ...
-; %niter.nsub.1 = add nsw i32 %niter.nsub, -1
+; %dec18.1 = add nsw i32 %dec18, -1
; should be merged to:
-; %dec18.1 = add nsw i32 %niter, -2
+; %dec18.1 = add nsw i32 %dec18.in, -2
;
; CHECK-LABEL: @_Z3fn1v(
-; CHECK: %niter.nsub.1 = add i32 %niter, -2
+; CHECK: %dec18.1 = add nsw i32 %dec18.in, -2
; ModuleID = '<stdin>'
target triple = "x86_64-unknown-linux-gnu"
!3 = !{!3, !4}
!4 = !{!"llvm.loop.unroll.full"}
-; #pragma clang loop unroll(full)
-; Loop should be fully unrolled, even for optsize.
-;
-; CHECK-LABEL: @loop64_with_full_optsize(
-; CHECK-NOT: br i1
-define void @loop64_with_full_optsize(i32* nocapture %a) optsize {
-entry:
- br label %for.body
-
-for.body: ; preds = %for.body, %entry
- %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
- %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
- %0 = load i32, i32* %arrayidx, align 4
- %inc = add nsw i32 %0, 1
- store i32 %inc, i32* %arrayidx, align 4
- %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
- %exitcond = icmp eq i64 %indvars.iv.next, 64
- br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !3
-
-for.end: ; preds = %for.body
- ret void
-}
-
; #pragma clang loop unroll_count(4)
; Loop should be unrolled 4 times.
;
; should be duplicated (original and 4x unrolled).
;
; CHECK-LABEL: @runtime_loop_with_count4(
-; CHECK: for.body
+; CHECK: for.body.prol:
; CHECK: store
+; CHECK-NOT: store
+; CHECK: br i1
+; CHECK: for.body
; CHECK: store
; CHECK: store
; CHECK: store
-; CHECK-NOT: store
-; CHECK: br i1
-; CHECK: for.body.epil:
; CHECK: store
; CHECK-NOT: store
; CHECK: br i1
; (original and 8x).
;
; CHECK-LABEL: @runtime_loop_with_enable(
+; CHECK: for.body.prol:
+; CHECK: store
+; CHECK-NOT: store
+; CHECK: br i1
; CHECK: for.body:
; CHECK: store i32
; CHECK: store i32
; CHECK: store i32
; CHECK-NOT: store i32
; CHECK: br i1
-; CHECK: for.body.epil:
-; CHECK: store
-; CHECK-NOT: store
-; CHECK: br i1
define void @runtime_loop_with_enable(i32* nocapture %a, i32 %b) {
entry:
%cmp3 = icmp sgt i32 %b, 0
; should be duplicated (original and 3x unrolled).
;
; CHECK-LABEL: @runtime_loop_with_count3(
-; CHECK: for.body
-; CHECK: store
-; CHECK: store
+; CHECK: for.body.prol:
; CHECK: store
; CHECK-NOT: store
; CHECK: br i1
-; CHECK: for.body.epil:
+; CHECK: for.body
+; CHECK: store
+; CHECK: store
; CHECK: store
; CHECK-NOT: store
; CHECK: br i1