[llvm] [SystemZ] Improve CCMask optimization (PR #171137)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 10:19:10 PST 2025


================
@@ -8932,10 +8937,17 @@ SDValue SystemZTargetLowering::combineSELECT_CCMASK(
     }
     return SmallVector<SDValue, 4>{Val, Val, Val, Val};
   };
-  // Attempting to optimize TrueVal/FalseVal in outermost select_ccmask either
-  // with CCReg found by combineCCMask or original CCReg.
+
+  // Attempting to optimize TrueVal/FalseVal in outermost select_ccmask.
   SDValue TrueVal = N->getOperand(0);
   SDValue FalseVal = N->getOperand(1);
+  // First, if the condition is trivially false or trivially true after
+  // combineCCMask, just collapse this SELECT_CCMASK to the indicated value.
+  if (CCMaskVal == 0)
+    return FalseVal;
+  if (CCMaskVal == CCValidVal)
+    return TrueVal;
----------------
uweigand wrote:

Why not do this right at the end?   The subsequent block probably cannot re-introduce an all-false or all-true mask, but it still might be better to just do this check at the end.

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


More information about the llvm-commits mailing list