[llvm] [Vectorizer] Conversion of icmp eq to icmp ult to enable vectorization (PR #202368)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 08:34:06 PDT 2026
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/Vectorize/SLPVectorizer.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/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 408ebbae1..5688de591 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12801,37 +12801,37 @@ void BoUpSLP::buildTreeRec(ArrayRef<Value *> VLRef, unsigned Depth,
SmallVector<Value *> VL(VLRef);
if (VL.size() > 1 && isa<ICmpInst>(VL[0])) {
- // Changes icmp eq %x, 0 -> icmp ult %x, 1 when the rest of
- // the instructions are icmp ult .. . This prevents to move
- // towards altShuffle path.
- bool HasEqZero = false;
- bool AllUltOrEqZero = all_of(VL, [&HasEqZero](Value *V) {
- auto *Cmp = dyn_cast<ICmpInst>(V);
- if (!Cmp)
- return isa<PoisonValue>(V);
- if (Cmp->getPredicate() == ICmpInst::ICMP_ULT)
- return true;
- if (Cmp->getPredicate() == ICmpInst::ICMP_EQ)
- if (auto *C = dyn_cast<ConstantInt>(Cmp->getOperand(1)))
- if (C->isZero()) {
- HasEqZero = true;
- return true;
- }
- return false;
- });
-
- if (HasEqZero && AllUltOrEqZero) {
- for (Value *V : VL) {
+ // Changes icmp eq %x, 0 -> icmp ult %x, 1 when the rest of
+ // the instructions are icmp ult .. . This prevents to move
+ // towards altShuffle path.
+ bool HasEqZero = false;
+ bool AllUltOrEqZero = all_of(VL, [&HasEqZero](Value *V) {
auto *Cmp = dyn_cast<ICmpInst>(V);
- if (!Cmp || Cmp->getPredicate() != ICmpInst::ICMP_EQ)
- continue;
- Cmp->setPredicate(ICmpInst::ICMP_ULT);
- Cmp->setOperand(1, ConstantInt::get(Cmp->getOperand(1)->getType(), 1));
- LLVM_DEBUG(dbgs() << "SLP: Canonicalized icmp eq 0 to ult 1: "
- << *Cmp << "\n");
+ if (!Cmp)
+ return isa<PoisonValue>(V);
+ if (Cmp->getPredicate() == ICmpInst::ICMP_ULT)
+ return true;
+ if (Cmp->getPredicate() == ICmpInst::ICMP_EQ)
+ if (auto *C = dyn_cast<ConstantInt>(Cmp->getOperand(1)))
+ if (C->isZero()) {
+ HasEqZero = true;
+ return true;
+ }
+ return false;
+ });
+
+ if (HasEqZero && AllUltOrEqZero) {
+ for (Value *V : VL) {
+ auto *Cmp = dyn_cast<ICmpInst>(V);
+ if (!Cmp || Cmp->getPredicate() != ICmpInst::ICMP_EQ)
+ continue;
+ Cmp->setPredicate(ICmpInst::ICMP_ULT);
+ Cmp->setOperand(1, ConstantInt::get(Cmp->getOperand(1)->getType(), 1));
+ LLVM_DEBUG(dbgs() << "SLP: Canonicalized icmp eq 0 to ult 1: " << *Cmp
+ << "\n");
+ }
}
}
-}
// Tries to build split node.
auto TrySplitNode = [&](const InstructionsState &LocalState) {
SmallVector<Value *> Op1, Op2;
``````````
</details>
https://github.com/llvm/llvm-project/pull/202368
More information about the llvm-commits
mailing list