[PATCH] D119148: [LoopUnroll] Always respect user unroll pragma
Whitney Tsang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 7 09:29:06 PST 2022
Whitney updated this revision to Diff 406502.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119148/new/
https://reviews.llvm.org/D119148
Files:
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/test/Transforms/LoopUnroll/unroll-pragmas.ll
Index: llvm/test/Transforms/LoopUnroll/unroll-pragmas.ll
===================================================================
--- llvm/test/Transforms/LoopUnroll/unroll-pragmas.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-pragmas.ll
@@ -235,33 +235,6 @@
!10 = !{!10, !11}
!11 = !{!"llvm.loop.unroll.count", i32 1}
-; #pragma clang loop unroll(full)
-; Loop has very high loop count (1 million) and full unrolling was requested.
-; Loop should unrolled up to the pragma threshold, but not completely.
-;
-; CHECK-LABEL: @unroll_1M(
-; CHECK: store i32
-; CHECK: store i32
-; CHECK: br i1
-define void @unroll_1M(i32* nocapture %a, i32 %b) {
-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, 1000000
- br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !12
-
-for.end: ; preds = %for.body
- ret void
-}
-!12 = !{!12, !4}
-
; #pragma clang loop unroll(enable)
; Loop should be fully unrolled.
;
Index: llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -788,14 +788,12 @@
// 2nd priority is unroll count set by pragma.
if (PInfo.PragmaCount > 0) {
- if ((UP.AllowRemainder || (TripMultiple % PInfo.PragmaCount == 0)) &&
- UCE.getUnrolledLoopSize(UP, PInfo.PragmaCount) < PragmaUnrollThreshold)
+ if ((UP.AllowRemainder || (TripMultiple % PInfo.PragmaCount == 0)))
return PInfo.PragmaCount;
}
if (PInfo.PragmaFullUnroll && TripCount != 0) {
- if (UCE.getUnrolledLoopSize(UP, TripCount) < PragmaUnrollThreshold)
- return TripCount;
+ return TripCount;
}
// if didn't return until here, should continue to other priorties
return None;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119148.406502.patch
Type: text/x-patch
Size: 2223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220207/b3b661e1/attachment.bin>
More information about the llvm-commits
mailing list