[llvm] [DAG] Add legalization handling for AVGCEIL/AVGFLOOR nodes (PR #92096)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed May 22 09:02:11 PDT 2024
================
@@ -4560,8 +4560,15 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
Tmp = ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
// SRA X, C -> adds C sign bits.
if (const APInt *ShAmt =
- getValidMinimumShiftAmountConstant(Op, DemandedElts))
+ getValidMinimumShiftAmountConstant(Op, DemandedElts)) {
Tmp = std::min<uint64_t>(Tmp + ShAmt->getZExtValue(), VTBits);
+ } else {
+ KnownBits KnownAmt =
+ computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
+ if (KnownAmt.isConstant() && KnownAmt.getConstant().ult(VTBits))
+ Tmp = std::min<uint64_t>(Tmp + KnownAmt.getConstant().getZExtValue(),
+ VTBits);
+ }
----------------
jayfoad wrote:
Isn't there any helper simpler than computeKnownBits that can look through bitcasts to find a constant?
If you _are_ going to use computeKnownBits, why not use `KnownAmt.getMinValue()` instead of `KnownAmt.getConstant()`?
https://github.com/llvm/llvm-project/pull/92096
More information about the llvm-commits
mailing list