[PATCH] D101368: [SimplifyCFG] Optionally update LI in sinkCommonCodeFromPredecessors.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 27 07:54:56 PDT 2021


fhahn created this revision.
fhahn added reviewers: spatel, RKSimon, lebedev.ri.
Herald added a subscriber: hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

LI can easily preserved by sinkCommonCodeFromPredecessors by passing
through LI to SplitBlockPredecessors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101368

Files:
  llvm/include/llvm/Transforms/Utils/Local.h
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1926,7 +1926,8 @@
 // true, sink any common code from the predecessors to BB.
 // We also allow one predecessor to end with conditional branch (but no more
 // than one).
-bool llvm::sinkCommonCodeFromPredecessors(BasicBlock *BB, DomTreeUpdater *DTU) {
+bool llvm::sinkCommonCodeFromPredecessors(BasicBlock *BB, DomTreeUpdater *DTU,
+                                          LoopInfo *LI) {
   // We support two situations:
   //   (1) all incoming arcs are unconditional
   //   (2) one incoming arc is conditional
@@ -2044,7 +2045,7 @@
     LLVM_DEBUG(dbgs() << "SINK: Splitting edge\n");
     // We have a conditional edge and we're going to sink some instructions.
     // Insert a new block postdominating all blocks we're going to sink from.
-    if (!SplitBlockPredecessors(BB, UnconditionalPreds, ".sink.split", DTU))
+    if (!SplitBlockPredecessors(BB, UnconditionalPreds, ".sink.split", DTU, LI))
       // Edges couldn't be split.
       return false;
     Changed = true;
Index: llvm/include/llvm/Transforms/Utils/Local.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/Local.h
+++ llvm/include/llvm/Transforms/Utils/Local.h
@@ -57,6 +57,7 @@
 class StoreInst;
 class TargetLibraryInfo;
 class TargetTransformInfo;
+class LoopInfo;
 
 //===----------------------------------------------------------------------===//
 //  Local constant propagation.
@@ -189,7 +190,8 @@
 /// true, sink any common code from the predecessors to BB.
 /// We also allow one predecessor to end with conditional branch (but no more
 /// than one).
-bool sinkCommonCodeFromPredecessors(BasicBlock *BB, DomTreeUpdater *DTU);
+bool sinkCommonCodeFromPredecessors(BasicBlock *BB, DomTreeUpdater *DTU,
+                                    LoopInfo *LI = nullptr);
 
 /// This function is used to flatten a CFG. For example, it uses parallel-and
 /// and parallel-or mode to collapse if-conditions and merge if-regions with


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101368.340848.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/497d4eb4/attachment.bin>


More information about the llvm-commits mailing list