@@ -7532,8 +7532,9 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
75327532
75337533 // Fold (and X, (add (not Y), Z)) -> (and X, (not (sub Y, Z)))
75347534 // Fold (and X, (sub (not Y), Z)) -> (and X, (not (add Y, Z)))
7535- if (SDValue Folded = foldBitwiseOpWithNeg(N, DL, VT))
7536- return Folded;
7535+ if (TLI.hasAndNot(SDValue(N, 0)))
7536+ if (SDValue Folded = foldBitwiseOpWithNeg(N, DL, VT))
7537+ return Folded;
75377538
75387539 // Fold (and (srl X, C), 1) -> (srl X, BW-1) for signbit extraction
75397540 // If we are shifting down an extended sign bit, see if we can simplify
@@ -8212,11 +8213,6 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
82128213 }
82138214 }
82148215
8215- // Fold (or X, (add (not Y), Z)) -> (or X, (not (sub Y, Z)))
8216- // Fold (or X, (sub (not Y), Z)) -> (or X, (not (add Y, Z)))
8217- if (SDValue Folded = foldBitwiseOpWithNeg(N, DL, VT))
8218- return Folded;
8219-
82208216 // fold (or x, 0) -> x
82218217 if (isNullConstant(N1))
82228218 return N0;
@@ -9868,10 +9864,6 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
98689864 return DAG.getNode(ISD::ROTL, DL, VT, DAG.getSignedConstant(~1, DL, VT),
98699865 N0.getOperand(1));
98709866 }
9871- // Fold (xor X, (add (not Y), Z)) -> (xor X, (not (sub Y, Z)))
9872- // Fold (xor X, (sub (not Y), Z)) -> (xor X, (not (add Y, Z)))
9873- if (SDValue Folded = foldBitwiseOpWithNeg(N, DL, VT))
9874- return Folded;
98759867
98769868 // Simplify: xor (op x...), (op y...) -> (op (xor x, y))
98779869 if (N0Opcode == N1.getOpcode())
@@ -11626,9 +11618,6 @@ SDValue DAGCombiner::foldShiftToAvg(SDNode *N) {
1162611618}
1162711619
1162811620SDValue DAGCombiner::foldBitwiseOpWithNeg(SDNode *N, const SDLoc &DL, EVT VT) {
11629- if (!TLI.hasAndNot(SDValue(N, 0)))
11630- return SDValue();
11631-
1163211621 unsigned Opc = N->getOpcode();
1163311622 SDValue X, Y, Z, NotY;
1163411623 if (sd_match(N, m_BitwiseLogic(m_Value(X), m_Add(m_AllOf(m_Value(NotY),
0 commit comments