[llvm] [InstCombine] Generalize and consolidate phi translation check (PR #106051)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 09:26:22 PDT 2024


================
@@ -1785,9 +1784,31 @@ Instruction *InstCombinerImpl::foldOpIntoPhi(Instruction &I, PHINode *PN) {
     // Otherwise, we can replace *all* users with the new PHI we form.
   }
 
+  // Check that all operands are phi-translatable.
+  for (Value *Op : I.operands()) {
+    if (Op == PN)
+      continue;
+
+    // Non-instructions never require phi-translation.
+    auto *OpI = dyn_cast<Instruction>(Op);
+    if (!OpI)
+      continue;
+
+    // Can phi-translate phi nodes in the same block.
----------------
goldsteinn wrote:

nit: "Can phi-translate..." -> "Phi-translate can handle..."

https://github.com/llvm/llvm-project/pull/106051


More information about the llvm-commits mailing list