[PATCH] D136781: ensure loop-simplifed form when running loop-fusion pass with new-PM
MengXuan Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 26 12:23:04 PDT 2022
Narutoworld created this revision.
Narutoworld added reviewers: bjope, aeubanks.
Narutoworld added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Narutoworld requested review of this revision.
This patch tries to fix this issue <https://github.com/llvm/llvm-project/issues/50379>.
Loop Fusion (Function Pass) requires loops in simplified form. With legacy-pm, **loop-simplify** pass is added as a dependency for **loop-fusion**. But the new pass manager does not always ensure this format. This patch tries to invoke simplifyLoop() on loops that are not in simplified form.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136781
Files:
llvm/lib/Transforms/Scalar/LoopFuse.cpp
llvm/test/Transforms/LoopFusion/ensure_loop_simplify_form.ll
Index: llvm/test/Transforms/LoopFusion/ensure_loop_simplify_form.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopFusion/ensure_loop_simplify_form.ll
@@ -0,0 +1,19 @@
+; RUN: opt -enable-new-pm=1 -loop-fusion < %s
+
+define dso_local void @v_5_0() {
+entry:
+ br label %for.body
+
+for.cond.cleanup: ; preds = %for.body
+ br i1 undef, label %for.body6, label %for.cond.cleanup5
+
+for.body: ; preds = %for.body, %entry
+ br i1 undef, label %for.cond.cleanup, label %for.body
+
+for.cond.cleanup5: ; preds = %for.cond.cleanup
+ ret void
+
+for.body6: ; preds = %for.body6, %for.cond.cleanup
+ %v_loop_2.0.v_loop_2.0.v_loop_2.0.18 = load volatile i32, i32* undef, align 1
+ br label %for.body6
+}
Index: llvm/lib/Transforms/Scalar/LoopFuse.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -67,6 +67,7 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/CodeMoverUtils.h"
#include "llvm/Transforms/Utils/LoopPeel.h"
+#include "llvm/Transforms/Utils/LoopSimplify.h"
using namespace llvm;
@@ -593,6 +594,13 @@
});
}
#endif
+ for (Loop *L : LV) {
+ if (!L->isLoopSimplifyForm())
+ Changed |= simplifyLoop(L, &DT, <, &SE, &AC, nullptr,
+ /*PreserveLCSSA=*/false);
+ }
+ if (Changed)
+ PDT.recalculate(F);
collectFusionCandidates(LV);
Changed |= fuseCandidates();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136781.470899.patch
Type: text/x-patch
Size: 1754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/dae779a3/attachment.bin>
More information about the llvm-commits
mailing list