[llvm] [DAGCombiner][RISCV] Optimize (zext nneg (truncate X)) if X has known sign bits. (PR #82227)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 00:13:40 PST 2024


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 64790064e82467b43c04a70b6e9873e6939be81f 132158c8a2dd13bd4b9c9a23297a134d4615b627 -- 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 b259d3e20c..030438a009 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13768,18 +13768,18 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
       if (OpBits == DestBits) {
         // Op is i32, Mid is i8, and Dest is i32.  If Op has more than 24 sign
         // bits, it is already ready.
-        if (NumSignBits > DestBits-MidBits)
+        if (NumSignBits > DestBits - MidBits)
           return Op;
       } else if (OpBits < DestBits) {
         // Op is i32, Mid is i8, and Dest is i64.  If Op has more than 24 sign
         // bits, just sext from i32.
         // FIXME: This can probably be ZERO_EXTEND nneg?
-        if (NumSignBits > OpBits-MidBits)
+        if (NumSignBits > OpBits - MidBits)
           return DAG.getNode(ISD::SIGN_EXTEND, DL, VT, Op);
       } else {
         // Op is i64, Mid is i8, and Dest is i32.  If Op has more than 56 sign
         // bits, just truncate to i32.
-        if (NumSignBits > OpBits-MidBits)
+        if (NumSignBits > OpBits - MidBits)
           return DAG.getNode(ISD::TRUNCATE, DL, VT, Op);
       }
     }

``````````

</details>


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


More information about the llvm-commits mailing list