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

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 06:24:04 PST 2025


================
@@ -6648,6 +6649,59 @@ 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 (OptLevel == CodeGenOptLevel::None ||
----------------
TelGome wrote:

Thanks for the catch. I have removed it. I also updated the tests to include the negative cases.

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


More information about the llvm-commits mailing list