[llvm] [X86] Improve KnownBits for X86ISD::PSADBW nodes (PR #83830)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 05:31:24 PST 2024
================
@@ -36836,12 +36836,23 @@ void X86TargetLowering::computeKnownBitsForTargetNode(const SDValue Op,
break;
}
case X86ISD::PSADBW: {
+ SDValue LHS = Op.getOperand(0);
+ SDValue RHS = Op.getOperand(1);
assert(VT.getScalarType() == MVT::i64 &&
- Op.getOperand(0).getValueType().getScalarType() == MVT::i8 &&
+ LHS.getValueType() == RHS.getValueType() &&
+ LHS.getValueType().getScalarType() == MVT::i8 &&
"Unexpected PSADBW types");
- // PSADBW - fills low 16 bits and zeros upper 48 bits of each i64 result.
- Known.Zero.setBitsFrom(16);
+ KnownBits Known2;
+ unsigned NumSrcElts = LHS.getValueType().getVectorNumElements();
+ APInt DemandedSrcElts = APIntOps::ScaleBitMask(DemandedElts, NumSrcElts);
+ Known = DAG.computeKnownBits(RHS, DemandedSrcElts, Depth + 1);
+ Known2 = DAG.computeKnownBits(LHS, DemandedSrcElts, Depth + 1);
+ Known = KnownBits::absdiff(Known, Known2).zext(16);
+ Known = KnownBits::computeForAddSub(true, true, Known, Known);
+ Known = KnownBits::computeForAddSub(true, true, Known, Known);
+ Known = KnownBits::computeForAddSub(true, true, Known, Known);
----------------
phoebewang wrote:
Copy & paste error?
https://github.com/llvm/llvm-project/pull/83830
More information about the llvm-commits
mailing list