@@ -15119,22 +15119,20 @@ SDValue SITargetLowering::performPtrAddCombine(SDNode *N,
15119
15119
SDValue X = N0;
15120
15120
SDValue Y = N1.getOperand(0);
15121
15121
SDValue Z = N1.getOperand(1);
15122
- bool N1OneUse = N1.hasOneUse();
15123
- bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
15124
- bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
15125
- if ((ZIsConstant != YIsConstant) && N1OneUse) {
15126
- SDNodeFlags Flags;
15127
- // If both additions in the original were NUW, the new ones are as well.
15128
- if (N->getFlags().hasNoUnsignedWrap() &&
15129
- N1->getFlags().hasNoUnsignedWrap())
15130
- Flags |= SDNodeFlags::NoUnsignedWrap;
15131
-
15132
- if (YIsConstant)
15133
- std::swap(Y, Z);
15134
-
15135
- SDValue Inner = DAG.getMemBasePlusOffset(X, Y, DL, Flags);
15136
- DCI.AddToWorklist(Inner.getNode());
15137
- return DAG.getMemBasePlusOffset(Inner, Z, DL, Flags);
15122
+ if (N1.hasOneUse()) {
15123
+ bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
15124
+ bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
15125
+ if (ZIsConstant != YIsConstant) {
15126
+ // If both additions in the original were NUW, the new ones are as well.
15127
+ SDNodeFlags Flags =
15128
+ (N->getFlags() & N1->getFlags()) & SDNodeFlags::NoUnsignedWrap;
15129
+ if (YIsConstant)
15130
+ std::swap(Y, Z);
15131
+
15132
+ SDValue Inner = DAG.getMemBasePlusOffset(X, Y, DL, Flags);
15133
+ DCI.AddToWorklist(Inner.getNode());
15134
+ return DAG.getMemBasePlusOffset(Inner, Z, DL, Flags);
15135
+ }
15138
15136
}
15139
15137
}
15140
15138
0 commit comments