[llvm] [DAG] isSplatValue - only accept binop splats if they share all the same demanded undef elements (PR #135597)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 14 02:59:02 PDT 2025
================
@@ -3002,8 +3002,12 @@ bool SelectionDAG::isSplatValue(SDValue V, const APInt &DemandedElts,
APInt UndefLHS, UndefRHS;
SDValue LHS = V.getOperand(0);
SDValue RHS = V.getOperand(1);
+ // Ensure the same demanded undef elts for both operands, otherwise we might
+ // fail to handle binop-specific undef handling.
+ // e.g. (and undef, 0) -> 0 etc.
if (isSplatValue(LHS, DemandedElts, UndefLHS, Depth + 1) &&
- isSplatValue(RHS, DemandedElts, UndefRHS, Depth + 1)) {
+ isSplatValue(RHS, DemandedElts, UndefRHS, Depth + 1) &&
+ (DemandedElts & UndefLHS) == (DemandedElts & UndefRHS)) {
----------------
nikic wrote:
Hm, wouldn't it be sufficient to set `UndefElts = UndefLHS & UndefRHS`, but still have isSplatValue() return true?
https://github.com/llvm/llvm-project/pull/135597
More information about the llvm-commits
mailing list