@@ -2814,10 +2814,16 @@ bool TargetLowering::SimplifyDemandedBits(
2814
2814
unsigned DemandedBitsLZ = DemandedBits.countl_zero();
2815
2815
APInt LoMask = APInt::getLowBitsSet(BitWidth, BitWidth - DemandedBitsLZ);
2816
2816
KnownBits KnownOp0, KnownOp1;
2817
- if (SimplifyDemandedBits(Op0, LoMask, DemandedElts, KnownOp0, TLO,
2818
- Depth + 1) ||
2819
- SimplifyDemandedBits(Op1, LoMask, DemandedElts, KnownOp1, TLO,
2817
+ auto GetDemandedBitsLHSMask = [&](APInt Demanded,
2818
+ const KnownBits &KnownRHS) {
2819
+ if (Op.getOpcode() == ISD::MUL)
2820
+ Demanded.clearHighBits(KnownRHS.countMinTrailingZeros());
2821
+ return Demanded;
2822
+ };
2823
+ if (SimplifyDemandedBits(Op1, LoMask, DemandedElts, KnownOp1, TLO,
2820
2824
Depth + 1) ||
2825
+ SimplifyDemandedBits(Op0, GetDemandedBitsLHSMask(LoMask, KnownOp1),
2826
+ DemandedElts, KnownOp0, TLO, Depth + 1) ||
2821
2827
// See if the operation should be performed at a smaller bit width.
2822
2828
ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO)) {
2823
2829
if (Flags.hasNoSignedWrap() || Flags.hasNoUnsignedWrap()) {
0 commit comments