[NewGVN] Abort PHIOfOps if singleton PHI is found
authorManuelJBrito <manuel.brito@tecnico.ulisboa.pt>
Mon, 17 Jul 2023 15:51:40 +0000 (16:51 +0100)
committerManuelJBrito <manuel.brito@tecnico.ulisboa.pt>
Tue, 18 Jul 2023 09:22:09 +0000 (10:22 +0100)
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.

Differential Revision: https://reviews.llvm.org/D155478

llvm/lib/Transforms/Scalar/NewGVN.cpp

index 194a205..1af40e2 100644 (file)
@@ -2749,10 +2749,10 @@ NewGVN::makePossiblePHIOfOps(Instruction *I,
       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)