@@ -13870,24 +13870,22 @@ static SDValue tryFoldMADwithSRL(SelectionDAG &DAG, const SDLoc &SL,
1387013870 if (MulLHS.getValueType() != MVT::i64 || MulLHS.getOpcode() != ISD::SRL)
1387113871 return SDValue();
1387213872
13873- if (MulLHS.getOperand(1).getOpcode() != ISD::Constant ||
13874- MulLHS.getOperand(0) != AddRHS)
13873+ ConstantSDNode *ShiftVal = dyn_cast<ConstantSDNode> (MulLHS.getOperand(1));
13874+ if (!ShiftVal || MulLHS.getOperand(0) != AddRHS)
1387513875 return SDValue();
1387613876
13877- if (cast<ConstantSDNode>(MulLHS->getOperand(1)) ->getAsZExtVal() != 32)
13877+ if (ShiftVal ->getAsZExtVal() != 32)
1387813878 return SDValue();
1387913879
13880- APInt Const = cast <ConstantSDNode>(MulRHS.getNode())->getAPIntValue();
13880+ APInt Const = dyn_cast <ConstantSDNode>(MulRHS.getNode())->getAPIntValue();
1388113881 if (!Const.isNegative() || !Const.isSignedIntN(33))
1388213882 return SDValue();
1388313883
1388413884 SDValue ConstMul =
1388513885 DAG.getConstant(Const.getZExtValue() & 0x00000000FFFFFFFF, SL, MVT::i32);
13886- AddRHS = DAG.getNode(ISD::AND, SL, MVT::i64, AddRHS,
13887- DAG.getConstant(0x00000000FFFFFFFF, SL, MVT::i64));
1388813886 return getMad64_32(DAG, SL, MVT::i64,
1388913887 DAG.getNode(ISD::TRUNCATE, SL, MVT::i32, MulLHS), ConstMul,
13890- AddRHS, false);
13888+ DAG.getZeroExtendInReg( AddRHS, SL, MVT::i32) , false);
1389113889}
1389213890
1389313891// Fold (add (mul x, y), z) --> (mad_[iu]64_[iu]32 x, y, z) plus high
@@ -13948,8 +13946,7 @@ SDValue SITargetLowering::tryFoldToMad64_32(SDNode *N,
1394813946 SDValue MulRHS = LHS.getOperand(1);
1394913947 SDValue AddRHS = RHS;
1395013948
13951- if (MulLHS.getOpcode() == ISD::Constant ||
13952- MulRHS.getOpcode() == ISD::Constant) {
13949+ if (isa<ConstantSDNode>(MulLHS) || isa<ConstantSDNode>(MulRHS)) {
1395313950 if (MulRHS.getOpcode() == ISD::SRL)
1395413951 std::swap(MulLHS, MulRHS);
1395513952
0 commit comments