summaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-11-11 21:05:14 +0000
committerFlorian Hahn <flo@fhahn.com>2025-11-11 21:05:44 +0000
commitc41ef17653d7e2eea2435abdf3e963406d270c85 (patch)
tree706f489e3120428be419c0d801777b4c67f46169 /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
parent810d99335baf80c668c528d5abe9169da3214651 (diff)
[VPlan] Add getSingleUser helper (NFC).
Add helper to make it easier to retrieve the single user of a VPUser.
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 345bc63081b8..14cea1c8fa67 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4226,18 +4226,16 @@ VectorizationFactor LoopVectorizationPlanner::selectVectorizationFactor() {
// Selects are only modelled in the legacy cost model for safe
// divisors.
case Instruction::Select: {
- VPValue *VPV = VPI->getVPSingleValue();
- if (VPV->getNumUsers() == 1) {
- if (auto *WR = dyn_cast<VPWidenRecipe>(*VPV->user_begin())) {
- switch (WR->getOpcode()) {
- case Instruction::UDiv:
- case Instruction::SDiv:
- case Instruction::URem:
- case Instruction::SRem:
- continue;
- default:
- break;
- }
+ if (auto *WR =
+ dyn_cast_or_null<VPWidenRecipe>(VPI->getSingleUser())) {
+ switch (WR->getOpcode()) {
+ case Instruction::UDiv:
+ case Instruction::SDiv:
+ case Instruction::URem:
+ case Instruction::SRem:
+ continue;
+ default:
+ break;
}
}
C += VPI->cost(VF, CostCtx);
@@ -6976,11 +6974,10 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
// the more accurate VPlan-based cost model.
for (VPRecipeBase &R : *Plan.getVectorPreheader()) {
auto *VPI = dyn_cast<VPInstruction>(&R);
- if (!VPI || VPI->getOpcode() != Instruction::Select ||
- VPI->getNumUsers() != 1)
+ if (!VPI || VPI->getOpcode() != Instruction::Select)
continue;
- if (auto *WR = dyn_cast<VPWidenRecipe>(*VPI->user_begin())) {
+ if (auto *WR = dyn_cast_or_null<VPWidenRecipe>(VPI->getSingleUser())) {
switch (WR->getOpcode()) {
case Instruction::UDiv:
case Instruction::SDiv: