[PATCH] D137672: [LoopFuse] Ensure inner loops are in loop simplified form under new PM

MengXuan Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 08:38:33 PST 2022


Narutoworld updated this revision to Diff 474779.
Narutoworld marked 2 inline comments as done.
Narutoworld added a comment.

update testcase based on comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137672

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
===================================================================
--- llvm/test/Transforms/LoopFusion/ensure_loop_simplify_form.ll
+++ llvm/test/Transforms/LoopFusion/ensure_loop_simplify_form.ll
@@ -33,3 +33,44 @@
   %v_loop_2.0.v_loop_2.0.v_loop_2.0.18 = load volatile i32, i32* %dummy, align 1
   br label %for.body6
 }
+
+define void @f943(i8* %dummy) {
+; CHECK-LABEL: @f943(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[FOR_COND32_I_I:%.*]]
+; CHECK:       for.cond32.i.i:
+; CHECK-NEXT:    br label [[FOR_BODY37_I_I:%.*]]
+; CHECK:       for.cond42.preheader.i.i:
+; CHECK-NEXT:    br i1 true, label [[FOR_BODY44_I_I_PREHEADER:%.*]], label [[FOR_END47_I_I:%.*]]
+; CHECK:       for.body44.i.i.preheader:
+; CHECK-NEXT:    br label [[FOR_BODY44_I_I:%.*]]
+; CHECK:       for.body37.i.i:
+; CHECK-NEXT:    br i1 true, label [[FOR_BODY37_I_I]], label [[FOR_COND42_PREHEADER_I_I:%.*]]
+; CHECK:       for.body44.i.i:
+; CHECK-NEXT:    store volatile i8 poison, i8* [[DUMMY:%.*]], align 1
+; CHECK-NEXT:    br i1 true, label [[FOR_BODY44_I_I]], label [[FOR_END47_I_I_LOOPEXIT:%.*]]
+; CHECK:       for.end47.i.i.loopexit:
+; CHECK-NEXT:    br label [[FOR_END47_I_I]]
+; CHECK:       for.end47.i.i:
+; CHECK-NEXT:    br label [[FOR_COND32_I_I]]
+;
+entry:
+  br label %for.cond32.i.i
+
+for.cond32.i.i:                                   ; preds = %for.end47.i.i, %entry
+  br label %for.body37.i.i
+
+for.cond42.preheader.i.i:                         ; preds = %for.body37.i.i
+  br i1 true, label %for.body44.i.i, label %for.end47.i.i
+
+for.body37.i.i:                                   ; preds = %for.body37.i.i, %for.cond32.i.i
+  br i1 true, label %for.body37.i.i, label %for.cond42.preheader.i.i
+
+for.body44.i.i:                                   ; preds = %for.body44.i.i, %for.cond42.preheader.i.i
+  store volatile i8 poison, i8* %dummy, align 1
+  br i1 true, label %for.body44.i.i, label %for.end47.i.i
+
+for.end47.i.i:                                    ; preds = %for.body44.i.i, %for.cond42.preheader.i.i
+  br label %for.cond32.i.i
+}
+
Index: llvm/lib/Transforms/Scalar/LoopFuse.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -2091,9 +2091,8 @@
   // LoopSimplify pass as a dependency.
   bool Changed = false;
   for (auto &L : LI) {
-    if (!L->isLoopSimplifyForm())
-      Changed |= simplifyLoop(L, &DT, &LI, &SE, &AC, nullptr,
-                              false /* PreserveLCSSA */);
+    Changed |=
+        simplifyLoop(L, &DT, &LI, &SE, &AC, nullptr, false /* PreserveLCSSA */);
   }
   if (Changed)
     PDT.recalculate(F);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137672.474779.patch
Type: text/x-patch
Size: 2749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221111/d2b1e386/attachment.bin>


More information about the llvm-commits mailing list