[PATCH] D155940: [SimplifyCFG] Transform for redirecting phis between unmergeable BB and SuccBB

DianQK via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 07:46:44 PDT 2023


DianQK accepted this revision.
DianQK added a comment.
This revision is now accepted and ready to land.

LGTM. But before landing, you'd better request @nikic approval for this.

> If possible, however, it would be better if there is any other available option that does not modify the original IR.

I don't know. The purpose of your transformation is to tweak this test case.



================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:886
     } else {
-      Value* Val = PN->getIncomingValueForBlock(BB);
+      Value *Val = PN->getIncomingValueForBlock(BB);
       for (unsigned PI = 0, PE = PN->getNumIncomingValues(); PI != PE; ++PI) {
----------------
Irrelevant formatting.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:1004
+static bool
+CanRedirectPredsOfEmptyBBToSucc(BasicBlock *BB, BasicBlock *Succ,
+                                const SmallPtrSetImpl<BasicBlock *> &BBPreds,
----------------
Should `clang-tidy` recommend lowercase beginnings?


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:1148
   // folding the branch isn't profitable in that case anyway.
+
   if (!Succ->getSinglePredecessor()) {
----------------
Irrelevant formatting.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:1153
       for (Use &U : BBI->uses()) {
-        if (PHINode* PN = dyn_cast<PHINode>(U.getUser())) {
+        if (PHINode *PN = dyn_cast<PHINode>(U.getUser())) {
           if (PN->getIncomingBlock(U) != BB)
----------------
Again.


================
Comment at: llvm/test/CodeGen/ARM/jump-table-islands.ll:39
   %val = phi %BigInt [ %l, %complex ], [ -1, %simple ]
+; Limit SimplifyCFG not to optimize phi node here
+  call void @use(%BigInt %val)
----------------
“The purpose is to prevent SimplifyCFG from simplifying the phi node above.”
Would this description be better?


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

https://reviews.llvm.org/D155940



More information about the llvm-commits mailing list