[llvm] [DAGCombine] Improve bswap loweing for machines that support bit rotates (PR #164848)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Oct 23 10:00: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 origin/main HEAD --extensions cpp -- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 94eb45e2d..3accdb722 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -9901,10 +9901,14 @@ SDValue TargetLowering::expandBSWAP(SDNode *N, SelectionDAG &DAG) const {
   case MVT::i32:
     if (isOperationLegal(ISD::ROTR, VT)) {
       // (x & 0x00FF00FF) rotl 8 | (x rotr 8) & 0x00FF00FF
-      SDValue And = DAG.getNode(ISD::AND, dl, VT, Op, DAG.getConstant(0x00FF00FF, dl, VT));
-      SDValue Rotl = DAG.getNode(ISD::ROTL, dl, VT, And, DAG.getConstant(8, dl, SHVT));
-      SDValue Rotr = DAG.getNode(ISD::ROTR, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
-      SDValue And2 = DAG.getNode(ISD::AND, dl, VT, Rotr, DAG.getConstant(0x00FF00FF, dl, VT));
+      SDValue And = DAG.getNode(ISD::AND, dl, VT, Op,
+                                DAG.getConstant(0x00FF00FF, dl, VT));
+      SDValue Rotl =
+          DAG.getNode(ISD::ROTL, dl, VT, And, DAG.getConstant(8, dl, SHVT));
+      SDValue Rotr =
+          DAG.getNode(ISD::ROTR, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
+      SDValue And2 = DAG.getNode(ISD::AND, dl, VT, Rotr,
+                                 DAG.getConstant(0x00FF00FF, dl, VT));
       return DAG.getNode(ISD::OR, dl, VT, Rotl, And2);
     }
     Tmp4 = DAG.getNode(ISD::SHL, dl, VT, Op, DAG.getConstant(24, dl, SHVT));
``````````
</details>
https://github.com/llvm/llvm-project/pull/164848
    
    
More information about the llvm-commits
mailing list