[PATCH] D121921: adjusting LoopRotationPass

Sergey Pupyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 09:53:22 PDT 2022


spupyrev created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
spupyrev requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

It seems the earlier implementation does not follow the description
in LoopRotationPass.h: It rotates loops even if they are already laid out
correctly. The diff adjusts the behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121921

Files:
  bolt/lib/Passes/LoopInversionPass.cpp


Index: bolt/lib/Passes/LoopInversionPass.cpp
===================================================================
--- bolt/lib/Passes/LoopInversionPass.cpp
+++ bolt/lib/Passes/LoopInversionPass.cpp
@@ -54,11 +54,17 @@
         }
       }
 
-      assert(SecondSucc != nullptr && "Unable to find second BB successor");
-      const uint64_t BBCount = SuccBB->getBranchInfo(*BB).Count;
-      const uint64_t OtherCount = SuccBB->getBranchInfo(*SecondSucc).Count;
-      if ((BBCount < OtherCount) && (BBIndex > SuccBBIndex))
-        continue;
+      assert(SecondSucc != nullptr && "Unable to find a second BB successor");
+      const uint64_t LoopCount = SuccBB->getBranchInfo(*BB).Count;
+      const uint64_t ExitCount = SuccBB->getBranchInfo(*SecondSucc).Count;
+
+      if (LoopCount < ExitCount) {
+        if (BBIndex > SuccBBIndex)
+          continue;
+      } else {
+        if (BBIndex < SuccBBIndex)
+          continue;
+      }
 
       IsChanged = true;
       BB->setLayoutIndex(SuccBBIndex);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121921.416219.patch
Type: text/x-patch
Size: 1009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220317/3c622be2/attachment.bin>


More information about the llvm-commits mailing list