[llvm] [DAGCombiner] Fold `sub nuw C, x` -> `xor x, C` when C is a mask (PR #192692)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 09:15:30 PDT 2026
================
@@ -4549,6 +4549,16 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
}
}
+ // sub nuw C, x --> xor x, C when C is a mask (2^k - 1)
+ if (ConstantSDNode *C0 = isConstOrConstSplat(N0)) {
+ if (N->getFlags().hasNoUnsignedWrap()) {
----------------
arsenm wrote:
There are other isConstOrConstSplat blocks already here, should move them together
https://github.com/llvm/llvm-project/pull/192692
More information about the llvm-commits
mailing list