[llvm] [DAG] Fold (and X, (add (not Y), Z)) -> (and X, (not (sub Y, Z))). (PR #141476)

Xu Zhang via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 3 04:27:55 PDT 2025


================
@@ -11609,6 +11625,28 @@ SDValue DAGCombiner::foldShiftToAvg(SDNode *N) {
   return DAG.getNode(FloorISD, SDLoc(N), N->getValueType(0), {A, B});
 }
 
+SDValue DAGCombiner::foldBitwiseOpWithNeg(SDNode *N, const SDLoc &DL, EVT VT) {
+  if (!TLI.hasAndNot(SDValue(N, 0)))
----------------
simonzgx wrote:

Got it, this approach sounds reasonable! When you mentioned "yak shaving" work, could you clarify exactly what needs to be done? Should those changes be included in this PR, or can we merge this patch first and handle them separately?

https://github.com/llvm/llvm-project/pull/141476


More information about the llvm-commits mailing list