[llvm] [DAG] Fold logic of zero-checks to multiplication for MinSize (PR #171805)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 30 10:13:28 PST 2026


================
@@ -6648,6 +6649,61 @@ static unsigned getMinMaxOpcodeForFP(SDValue Operand1, SDValue Operand2,
   return ISD::DELETED_NODE;
 }
 
+// Fold the following patterns for small integers in -Oz mode.
+// (X == 0) || (Y == 0) --> (X * Y) == 0
+// (X != 0) && (Y != 0) --> (X * Y) != 0
+SDValue DAGCombiner::foldLogicSetCCToMul(SDNode *N, const SDLoc &DL) {
+  if (!DAG.getMachineFunction().getFunction().hasMinSize())
+    return SDValue();
+
+  unsigned Opcode = N->getOpcode();
+  SDValue N0 = N->getOperand(0);
+  SDValue N1 = N->getOperand(1);
+
+  ISD::CondCode ExpectedCC;
+  if (Opcode == ISD::OR) {
----------------
arsenm wrote:

Don't need faces 

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


More information about the llvm-commits mailing list