[llvm] [LoopRotate] Rotate loop if this makes exit count computable (PR #162654)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 03:57:37 PST 2025


Marek =?utf-8?q?Sedláček?= <mr.mareksedlacek at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/162654 at github.com>


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/Transforms/Scalar/LoopRotation.h llvm/include/llvm/Transforms/Utils/LoopRotationUtils.h llvm/lib/Passes/PassBuilderPipelines.cpp llvm/lib/Transforms/Scalar/LoopRotation.cpp llvm/lib/Transforms/Utils/LoopRotationUtils.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopRotation.h b/llvm/include/llvm/Transforms/Scalar/LoopRotation.h
index a5299ad62..4117c1505 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopRotation.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopRotation.h
@@ -24,8 +24,7 @@ class Loop;
 class LoopRotatePass : public PassInfoMixin<LoopRotatePass> {
 public:
   LoopRotatePass(bool EnableHeaderDuplication = true,
-                 bool PrepareForLTO = false,
-                 bool RotateComputable = true);
+                 bool PrepareForLTO = false, bool RotateComputable = true);
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
 
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp
index 4fd092908..8cf0fa1ec 100644
--- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp
@@ -75,10 +75,10 @@ PreservedAnalyses LoopRotatePass::run(Loop &L, LoopAnalysisManager &AM,
   std::optional<MemorySSAUpdater> MSSAU;
   if (AR.MSSA)
     MSSAU = MemorySSAUpdater(AR.MSSA);
-  bool Changed = LoopRotation(&L, &AR.LI, &AR.TTI, &AR.AC, &AR.DT, &AR.SE,
-                              MSSAU ? &*MSSAU : nullptr, SQ, false, Threshold,
-                              false, PrepareForLTO || PrepareForLTOOption,
-                              RotateComputable);
+  bool Changed =
+      LoopRotation(&L, &AR.LI, &AR.TTI, &AR.AC, &AR.DT, &AR.SE,
+                   MSSAU ? &*MSSAU : nullptr, SQ, false, Threshold, false,
+                   PrepareForLTO || PrepareForLTOOption, RotateComputable);
 
   if (!Changed)
     return PreservedAnalyses::all();
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index 30c9e1028..06aae0d4e 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -379,8 +379,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
   // Rotate if the loop latch was just simplified. Or if it makes the loop exit
   // count computable. Or if we think it will be profitable.
   if (L->isLoopExiting(OrigLatch) && !SimplifiedLatch && IsUtilMode == false &&
-      !profitableToRotateLoopExitingLatch(L) && !(RotateComputable &&
-      rotationMakesLoopComputable(L, SE)))
+      !profitableToRotateLoopExitingLatch(L) &&
+      !(RotateComputable && rotationMakesLoopComputable(L, SE)))
     return Rotated;
 
   // Check size of original header and reject loop if it is very big or we can't

``````````

</details>


https://github.com/llvm/llvm-project/pull/162654


More information about the llvm-commits mailing list