[PATCH] D155478: [NewGVN] Abort PHIOfOps if found singleton PHI

Manuel Brito via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 09:01:52 PDT 2023


ManuelJBrito created this revision.
ManuelJBrito added a reviewer: nlopes.
Herald added subscribers: kmitropoulou, hiraditya.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently we just bypass singleton phis, however we know that in order to create the phi of ops all phis must be in the same block. Therefore if one phi is a singleton then the rest are as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155478

Files:
  llvm/lib/Transforms/Scalar/NewGVN.cpp


Index: llvm/lib/Transforms/Scalar/NewGVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -2749,10 +2749,10 @@
       return nullptr;
     }
     // No point in doing this for one-operand phis.
-    if (OpPHI->getNumOperands() == 1) {
-      OpPHI = nullptr;
-      continue;
-    }
+    // Since all PHIs for operands must be in the same block, then they must
+    // have the same number of operands so we can just abort.
+    if (OpPHI->getNumOperands() == 1)
+      return nullptr;
   }
 
   if (!OpPHI)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155478.541069.patch
Type: text/x-patch
Size: 618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230717/47344c45/attachment.bin>


More information about the llvm-commits mailing list