[llvm] [DAGCombiner] add fold (xor (smin(x, C), C)) and fold (xor (smax(x, C), C)) (PR #155141)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 24 00:17:31 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 011d38233..7b4c91425 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10092,17 +10092,17 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
     SDValue Op0 = N0.getOperand(0);
     SDValue Op1 = N0.getOperand(1);
 
-    if(Op1 != N1) {
+    if (Op1 != N1) {
       std::swap(Op0, Op1);
     }
 
     if (Op1 == N1) {
       if (isa<ConstantSDNode>(N1)) {
-          EVT CCVT = getSetCCResultType(VT);
-          SDValue Cmp = DAG.getSetCC(SDLoc(N), CCVT, Op0, N1, ISD::SETLT);
-          SDValue XorXC = DAG.getNode(ISD::XOR, SDLoc(N), VT, Op0, N1);
-          SDValue Zero = DAG.getConstant(0, SDLoc(N), VT);
-          return DAG.getSelect(SDLoc(N), VT, Cmp, XorXC, Zero);
+        EVT CCVT = getSetCCResultType(VT);
+        SDValue Cmp = DAG.getSetCC(SDLoc(N), CCVT, Op0, N1, ISD::SETLT);
+        SDValue XorXC = DAG.getNode(ISD::XOR, SDLoc(N), VT, Op0, N1);
+        SDValue Zero = DAG.getConstant(0, SDLoc(N), VT);
+        return DAG.getSelect(SDLoc(N), VT, Cmp, XorXC, Zero);
       }
     }
   }
@@ -10113,7 +10113,7 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
     SDValue Op0 = N0.getOperand(0);
     SDValue Op1 = N0.getOperand(1);
 
-    if(Op1 != N1) {
+    if (Op1 != N1) {
       std::swap(Op0, Op1);
     }
 

``````````

</details>


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


More information about the llvm-commits mailing list