[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

Eric Christopher via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 20:21:14 PST 2019


echristo updated this revision to Diff 234656.
echristo added a comment.

Formatting and parens changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71687/new/

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/cfe-commits/attachments/20191219/f807d084/attachment.bin>


More information about the cfe-commits mailing list