[PATCH] D71687: Fix full loop unrolling initialization in new pass manager
Eric Christopher via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 20:21:14 PST 2019
echristo created this revision.
echristo added reviewers: chandlerc, hfinkel, asbirlea.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, mcrosier.
Herald added projects: clang, LLVM.
echristo updated this revision to Diff 234656.
echristo added a comment.
Formatting and parens changes.
Last we looked at this and couldn't come up with a reason to change it, but with a pragma for full loop unrolling we bypass every other loop unroll and then fail to fully unroll a loop when the pragma is set.
Move the OnlyWhenForced out of the check and into the initialization of the full unroll pass in the new pass manager. This doesn't show up with the old pass manager.
Tested with check-clang and check-llvm.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71687
Files:
clang/test/Misc/loop-opt-setup.c
llvm/lib/Passes/PassBuilder.cpp
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -478,10 +478,10 @@
// Do not enable unrolling in PreLinkThinLTO phase during sample PGO
// because it changes IR to makes profile annotation in back compile
// inaccurate.
- if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
- PGOOpt->Action != PGOOptions::SampleUse) &&
- PTO.LoopUnrolling)
- LPM2.addPass(LoopFullUnrollPass(Level, /*OnlyWhenForced=*/false,
+ if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+ PGOOpt->Action != PGOOptions::SampleUse)
+ LPM2.addPass(LoopFullUnrollPass(Level,
+ /*OnlyWhenForced=*/!PTO.LoopUnrolling,
PTO.ForgetAllSCEVInLoopUnroll));
for (auto &C : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===================================================================
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -8,5 +8,13 @@
a[i] = b += 2;
return b;
}
+
+int B(void) {
+#pragma clang loop unroll(full)
+ for (int i = 0; i < 16; ++i)
+ a[i] = b += 2;
+ return b;
+}
+
// CHECK-NOT: br i1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71687.234656.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191219/37d0031e/attachment.bin>
More information about the llvm-commits
mailing list