[llvm] [DAG] Generalize fold (not (neg x)) -> (add X, -1) (PR #154348)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 01:38:12 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 709c4293c..320e81b8f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9988,12 +9988,14 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
}
}
- // fold (not (sub Y, X)) -> (add X, ~Y) if Y is a constant or the subtract has a single use.
+ // fold (not (sub Y, X)) -> (add X, ~Y) if Y is a constant or the subtract has
+ // a single use.
if (isAllOnesConstant(N1) && N0.getOpcode() == ISD::SUB) {
SDValue Y = N0.getOperand(0);
SDValue X = N0.getOperand(1);
if (isa<ConstantSDNode>(Y) || N0.hasOneUse()) {
- SDValue NotY = DAG.getNode(ISD::XOR, DL, VT, Y, DAG.getAllOnesConstant(DL, VT));
+ SDValue NotY =
+ DAG.getNode(ISD::XOR, DL, VT, Y, DAG.getAllOnesConstant(DL, VT));
return DAG.getNode(ISD::ADD, DL, VT, X, NotY);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/154348
More information about the llvm-commits
mailing list