diff options
author | David Green <david.green@arm.com> | 2019-06-10 10:22:14 +0000 |
---|---|---|
committer | David Green <david.green@arm.com> | 2019-06-10 10:22:14 +0000 |
commit | d847aa573b655fe71aad323c7f579c6302c702aa (patch) | |
tree | 919db7aba20475f189e36d9bc8e0aaa34ee76d38 /llvm | |
parent | c6a930e4b4cd70b4c059d0c1c7d232269326b39b (diff) | |
download | bcm5719-llvm-d847aa573b655fe71aad323c7f579c6302c702aa.tar.gz bcm5719-llvm-d847aa573b655fe71aad323c7f579c6302c702aa.zip |
[ARM] Enable Unroll UpperBound
This option allows loops with small max trip counts to be fully unrolled. This
can help with code like the remainder loops from manually unrolled loops like
those that appear in the cmsis dsp library. We would apparently previously
runtime unroll them with the default unroll count (4).
Differential Revision: https://reviews.llvm.org/D63064
llvm-svn: 362928
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp index 6a8647ee0fd..c626c4149c7 100644 --- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp +++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp @@ -683,6 +683,7 @@ void ARMTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, UP.Partial = true; UP.Runtime = true; + UP.UpperBound = true; UP.UnrollRemainder = true; UP.DefaultUnrollRuntimeCount = 4; UP.UnrollAndJam = true; diff --git a/llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll b/llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll new file mode 100644 index 00000000000..b47bdc92cdc --- /dev/null +++ b/llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll @@ -0,0 +1,38 @@ +; RUN: opt -loop-unroll -S -mtriple arm-none-eabi -mcpu=cortex-m7 %s | FileCheck %s -check-prefix=UNROLL + +; This test is meant to check that this loop is unrolled into three iterations. + +; UNROLL-LABEL: @test +; UNROLL: load i32, i32* +; UNROLL: load i32, i32* +; UNROLL: load i32, i32* +; UNROLL-NOT: load i32, i32* + +define void @test(i32* %x, i32 %n) { +entry: + %sub = add nsw i32 %n, -1 + %rem = srem i32 %sub, 4 + %cmp7 = icmp sgt i32 %rem, 0 + br i1 %cmp7, label %while.body, label %while.end + +while.body: ; preds = %entry, %if.end + %x.addr.09 = phi i32* [ %incdec.ptr, %if.end ], [ %x, %entry ] + %n.addr.08 = phi i32 [ %dec, %if.end ], [ %rem, %entry ] + %0 = load i32, i32* %x.addr.09, align 4 + %cmp1 = icmp slt i32 %0, 10 + br i1 %cmp1, label %if.then, label %if.end + +if.then: ; preds = %while.body + store i32 0, i32* %x.addr.09, align 4 + br label %if.end + +if.end: ; preds = %if.then, %while.body + %incdec.ptr = getelementptr inbounds i32, i32* %x.addr.09, i32 1 + %dec = add nsw i32 %n.addr.08, -1 + %cmp = icmp sgt i32 %dec, 0 + br i1 %cmp, label %while.body, label %while.end + +while.end: ; preds = %if.end, %entry + ret void +} + |