diff options
Diffstat (limited to 'test/Transforms/LoopUnroll')
-rw-r--r-- | test/Transforms/LoopUnroll/X86/partial.ll | 51 | ||||
-rw-r--r-- | test/Transforms/LoopUnroll/loop-remarks.ll | 25 |
2 files changed, 74 insertions, 2 deletions
diff --git a/test/Transforms/LoopUnroll/X86/partial.ll b/test/Transforms/LoopUnroll/X86/partial.ll index 15867cb..a2b04c7 100644 --- a/test/Transforms/LoopUnroll/X86/partial.ll +++ b/test/Transforms/LoopUnroll/X86/partial.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -S -loop-unroll -mcpu=nehalem -x86-use-partial-unrolling=1 | FileCheck %s -; RUN: opt < %s -S -loop-unroll -mcpu=core -x86-use-partial-unrolling=1 | FileCheck -check-prefix=CHECK-NOUNRL %s +; RUN: opt < %s -S -loop-unroll -mcpu=nehalem | FileCheck %s +; RUN: opt < %s -S -loop-unroll -mcpu=core -unroll-runtime=0 | FileCheck -check-prefix=CHECK-NOUNRL %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -76,5 +76,52 @@ for.end: ; preds = %vector.body ret void } +define zeroext i16 @test1(i16* nocapture readonly %arr, i32 %n) #0 { +entry: + %cmp25 = icmp eq i32 %n, 0 + br i1 %cmp25, label %for.end, label %for.body + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %reduction.026 = phi i16 [ %add14, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i16* %arr, i64 %indvars.iv + %0 = load i16* %arrayidx, align 2 + %add = add i16 %0, %reduction.026 + %sext = mul i64 %indvars.iv, 12884901888 + %idxprom3 = ashr exact i64 %sext, 32 + %arrayidx4 = getelementptr inbounds i16* %arr, i64 %idxprom3 + %1 = load i16* %arrayidx4, align 2 + %add7 = add i16 %add, %1 + %sext28 = mul i64 %indvars.iv, 21474836480 + %idxprom10 = ashr exact i64 %sext28, 32 + %arrayidx11 = getelementptr inbounds i16* %arr, i64 %idxprom10 + %2 = load i16* %arrayidx11, align 2 + %add14 = add i16 %add7, %2 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + %reduction.0.lcssa = phi i16 [ 0, %entry ], [ %add14, %for.body ] + ret i16 %reduction.0.lcssa + +; This loop is too large to be partially unrolled (size=16) + +; CHECK-LABEL: @test1 +; CHECK: br +; CHECK: br +; CHECK: br +; CHECK: br +; CHECK-NOT: br + +; CHECK-NOUNRL-LABEL: @test1 +; CHECK-NOUNRL: br +; CHECK-NOUNRL: br +; CHECK-NOUNRL: br +; CHECK-NOUNRL: br +; CHECK-NOUNRL-NOT: br +} + attributes #0 = { nounwind uwtable } diff --git a/test/Transforms/LoopUnroll/loop-remarks.ll b/test/Transforms/LoopUnroll/loop-remarks.ll new file mode 100644 index 0000000..ff3ac17 --- /dev/null +++ b/test/Transforms/LoopUnroll/loop-remarks.ll @@ -0,0 +1,25 @@ +; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -unroll-count=16 2>&1 | FileCheck -check-prefix=COMPLETE-UNROLL %s +; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -unroll-count=4 2>&1 | FileCheck -check-prefix=PARTIAL-UNROLL %s + +; COMPLETE-UNROLL: remark: {{.*}}: completely unrolled loop with 16 iterations +; PARTIAL-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4 + +define i32 @sum() { +entry: + br label %for.body + +for.body: ; preds = %for.body, %entry + %s.06 = phi i32 [ 0, %entry ], [ %add1, %for.body ] + %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %add = add nsw i32 %i.05, 4 + %call = tail call i32 @baz(i32 %add) #2 + %add1 = add nsw i32 %call, %s.06 + %inc = add nsw i32 %i.05, 1 + %exitcond = icmp eq i32 %inc, 16 + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret i32 %add1 +} + +declare i32 @baz(i32) |