@@ -14968,22 +14968,20 @@ SDValue SITargetLowering::performPtrAddCombine(SDNode *N,
1496814968    SDValue X = N0;
1496914969    SDValue Y = N1.getOperand(0);
1497014970    SDValue Z = N1.getOperand(1);
14971-     bool N1OneUse = N1.hasOneUse();
14972-     bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
14973-     bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
14974-     if ((ZIsConstant != YIsConstant) && N1OneUse) {
14975-       SDNodeFlags Flags;
14976-       // If both additions in the original were NUW, the new ones are as well.
14977-       if (N->getFlags().hasNoUnsignedWrap() &&
14978-           N1->getFlags().hasNoUnsignedWrap())
14979-         Flags |= SDNodeFlags::NoUnsignedWrap;
14980- 
14981-       if (YIsConstant)
14982-         std::swap(Y, Z);
14983- 
14984-       SDValue Inner = DAG.getMemBasePlusOffset(X, Y, DL, Flags);
14985-       DCI.AddToWorklist(Inner.getNode());
14986-       return DAG.getMemBasePlusOffset(Inner, Z, DL, Flags);
14971+     if (N1.hasOneUse()) {
14972+       bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
14973+       bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
14974+       if (ZIsConstant != YIsConstant) {
14975+         // If both additions in the original were NUW, the new ones are as well.
14976+         SDNodeFlags Flags =
14977+             (N->getFlags() & N1->getFlags()) & SDNodeFlags::NoUnsignedWrap;
14978+         if (YIsConstant)
14979+           std::swap(Y, Z);
14980+ 
14981+         SDValue Inner = DAG.getMemBasePlusOffset(X, Y, DL, Flags);
14982+         DCI.AddToWorklist(Inner.getNode());
14983+         return DAG.getMemBasePlusOffset(Inner, Z, DL, Flags);
14984+       }
1498714985    }
1498814986  }
1498914987
0 commit comments