[llvm] SLPVectorizer: Avoid looking at uselists of constants (PR #134578)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 6 21:21:01 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/134578
This is an unproductive use of compile time
>From f2c7b6df4e8bbccf95bb88ee054f5566cf425790 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 7 Apr 2025 07:27:46 +0700
Subject: [PATCH] SLPVectorizer: Avoid looking at uselists of constants
This is an unproductive use of compile time
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 31c684e16f051..94c0289807245 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6273,7 +6273,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom,
SmallVector<Instruction *> UserBVHead(TE.Scalars.size());
for (auto [I, V] : zip(UserBVHead, TE.Scalars)) {
- if (!V->hasNUsesOrMore(1))
+ if (isa<Constant>(V) || !V->hasNUsesOrMore(1))
continue;
auto *II = dyn_cast<InsertElementInst>(*V->user_begin());
if (!II)
@@ -13433,7 +13433,7 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
allSameBlock(VectorizableTree.front()->Scalars));
if (any_of(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
return TE->isGather() && all_of(TE->Scalars, [&](Value *V) {
- return isa<ExtractElementInst, UndefValue>(V) ||
+ return isa<ExtractElementInst, Constant>(V) ||
(IsAllowedSingleBVNode &&
!V->hasNUsesOrMore(UsesLimit) &&
any_of(V->users(), IsaPred<InsertElementInst>));
@@ -19459,7 +19459,7 @@ bool BoUpSLP::collectValuesToDemote(
return FinalAnalysis();
if (any_of(E.Scalars, [&](Value *V) {
- return !all_of(V->users(), [=](User *U) {
+ return !isa<Constant>(V) && !all_of(V->users(), [=](User *U) {
return isVectorized(U) ||
(E.Idx == 0 && UserIgnoreList &&
UserIgnoreList->contains(U)) ||
More information about the llvm-commits
mailing list