[llvm] [SimpleLoopUnswitch] Record loops from unswitching non-trivial conditions (PR #141121)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu May 22 19:18:09 PDT 2025


================
@@ -2142,34 +2142,33 @@ void visitDomSubTree(DominatorTree &DT, BasicBlock *BB, CallableT Callable) {
 void postUnswitch(Loop &L, LPMUpdater &U, StringRef LoopName,
                   bool CurrentLoopValid, bool PartiallyInvariant,
                   bool InjectedCondition, ArrayRef<Loop *> NewLoops) {
-  // If we did a non-trivial unswitch, we have added new (cloned) loops.
-  if (!NewLoops.empty())
+  auto RecordLoopAsUnswitched = [&](Loop *TargetLoop, StringRef Tag) {
+    auto &Ctx = TargetLoop->getHeader()->getContext();
+    const auto &DisableMDName = (Twine(Tag) + ".disable").str();
----------------
dtcxzyw wrote:

`Twine::str` returns a temporary `std::string`. Can we add a parameter `StringRef DisableTag`  instead?


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


More information about the llvm-commits mailing list