@@ -15108,22 +15108,20 @@ SDValue SITargetLowering::performPtrAddCombine(SDNode *N,
1510815108 SDValue X = N0;
1510915109 SDValue Y = N1.getOperand(0);
1511015110 SDValue Z = N1.getOperand(1);
15111- bool N1OneUse = N1.hasOneUse();
15112- bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
15113- bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
15114- if ((ZIsConstant != YIsConstant) && N1OneUse) {
15115- SDNodeFlags Flags;
15116- // If both additions in the original were NUW, the new ones are as well.
15117- if (N->getFlags().hasNoUnsignedWrap() &&
15118- N1->getFlags().hasNoUnsignedWrap())
15119- Flags |= SDNodeFlags::NoUnsignedWrap;
15120-
15121- if (YIsConstant)
15122- std::swap(Y, Z);
15123-
15124- SDValue Inner = DAG.getMemBasePlusOffset(X, Y, DL, Flags);
15125- DCI.AddToWorklist(Inner.getNode());
15126- return DAG.getMemBasePlusOffset(Inner, Z, DL, Flags);
15111+ if (N1.hasOneUse()) {
15112+ bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
15113+ bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
15114+ if (ZIsConstant != YIsConstant) {
15115+ // If both additions in the original were NUW, the new ones are as well.
15116+ SDNodeFlags Flags =
15117+ (N->getFlags() & N1->getFlags()) & SDNodeFlags::NoUnsignedWrap;
15118+ if (YIsConstant)
15119+ std::swap(Y, Z);
15120+
15121+ SDValue Inner = DAG.getMemBasePlusOffset(X, Y, DL, Flags);
15122+ DCI.AddToWorklist(Inner.getNode());
15123+ return DAG.getMemBasePlusOffset(Inner, Z, DL, Flags);
15124+ }
1512715125 }
1512815126 }
1512915127
0 commit comments