[llvm] [GISel][CombinerHelper] Push freeze through non-poison-producing operands (PR #90618)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Sun May 19 03:29:32 PDT 2024


================
@@ -1750,13 +1759,26 @@ static bool isGuaranteedNotToBeUndefOrPoison(Register Reg,
 
   MachineInstr *RegDef = MRI.getVRegDef(Reg);
 
+  auto OpCheck = [&](MachineOperand &Operand) {
+    if (!Operand.isReg())
+      return true;
+
+    return isGuaranteedNotToBeUndefOrPoison(Operand.getReg(), MRI, Depth + 1,
+                                            Kind);
+  };
+
   switch (RegDef->getOpcode()) {
   case TargetOpcode::G_FREEZE:
     return true;
   case TargetOpcode::G_IMPLICIT_DEF:
     return !includesUndef(Kind);
   default:
-    return false;
+    GenericMachineInstr *Opr = dyn_cast<GBinOp>(RegDef);
+    if (!Opr)
+      Opr = dyn_cast<GCastOp>(RegDef);
+
+    return Opr && !::llvm::canCreateUndefOrPoison(Reg, MRI) &&
+           all_of(Opr->operands(), OpCheck);
----------------
tschuett wrote:

`Opr->operands()`  -> `RegDef->uses()`

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


More information about the llvm-commits mailing list