summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2018-12-18 17:16:05 +0000
committerMichael Kruse <llvm@meinersbur.de>2018-12-18 17:16:05 +0000
commit3284775b70865581df3f75f6731f7d6464b0f8aa (patch)
tree41c37ad09f91aac2bed4a762606fdf9084f9d175 /llvm/test/Transforms
parent53b5cfb08035ca02770d6c72752a55742fdd0f5e (diff)
downloadbcm5719-llvm-3284775b70865581df3f75f6731f7d6464b0f8aa.tar.gz
bcm5719-llvm-3284775b70865581df3f75f6731f7d6464b0f8aa.zip
[LoopUnroll] Honor '#pragma unroll' even with -fno-unroll-loops.
When using clang with `-fno-unroll-loops` (implicitly added with `-O1`), the LoopUnrollPass is not not added to the (legacy) pass pipeline. This also means that it will not process any loop metadata such as llvm.loop.unroll.enable (which is generated by #pragma unroll or WarnMissedTransformationsPass emits a warning that a forced transformation has not been applied (see https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20181210/610833.html). Such explicit transformations should take precedence over disabling heuristics. This patch unconditionally adds LoopUnrollPass to the optimizing pipeline (that is, it is still not added with `-O0`), but passes a flag indicating whether automatic unrolling is dis-/enabled. This is the same approach as LoopVectorize uses. The new pass manager's pipeline builder has no option to disable unrolling, hence the problem does not apply. Differential Revision: https://reviews.llvm.org/D55716 llvm-svn: 349509
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/LoopUnroll/disable-loop-unrolling_forced.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopUnroll/disable-loop-unrolling_forced.ll b/llvm/test/Transforms/LoopUnroll/disable-loop-unrolling_forced.ll
new file mode 100644
index 00000000000..9a0900df1a1
--- /dev/null
+++ b/llvm/test/Transforms/LoopUnroll/disable-loop-unrolling_forced.ll
@@ -0,0 +1,30 @@
+; RUN: opt -disable-loop-unrolling -O1 -S < %s | FileCheck %s
+;
+; Check loop unrolling metadata is honored despite automatic unrolling
+; being disabled in the pass builder.
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; CHECK-LABEL: @forced(
+; CHECK: load
+; CHECK: load
+define void @forced(i32* nocapture %a) {
+entry:
+ br label %for.body
+
+for.body:
+ %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 !0
+
+for.end:
+ ret void
+}
+
+!0 = distinct !{!0, !{!"llvm.loop.unroll.enable"},
+ !{!"llvm.loop.unroll.count", i32 2}}
OpenPOWER on IntegriCloud