[llvm] [InstCombine] Added optimisation for trunc (Pow2 >> x) to i1 (PR #157030)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 10:05:59 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/Transforms/InstCombine/InstCombineCasts.cpp
``````````
: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/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index df47acdb8..152d6f0b7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -975,8 +975,7 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
Value *V1;
// OP = { lshr, ashr }
// trunc ( OP i8 C1, V1) to i1 -> icmp eq V1, log_2(C1) iff C1 is power of 2
- if (DestWidth == 1 &&
- match(Src, m_Shr(m_Power2(C1), m_Value(V1)))) {
+ if (DestWidth == 1 && match(Src, m_Shr(m_Power2(C1), m_Value(V1)))) {
Value *Right = ConstantInt::get(V1->getType(), C1->countr_zero());
Value *Icmp = Builder.CreateICmpEQ(V1, Right);
return replaceInstUsesWith(Trunc, Icmp);
``````````
</details>
https://github.com/llvm/llvm-project/pull/157030
More information about the llvm-commits
mailing list