[llvm] [LV] Improve code around operands-iterator (NFC) (PR #156016)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 29 05:28:42 PDT 2025
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/156016
None
>From 3719271eea4d4531315badfb01d45ac7276d3faa Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Fri, 29 Aug 2025 13:23:08 +0100
Subject: [PATCH] [LV] Improve code around operands-iterator (NFC)
---
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6317bc3c20e25..c3bfcc5f80cd2 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6192,10 +6192,9 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
assert(Op0->getType()->getScalarSizeInBits() == 1 &&
Op1->getType()->getScalarSizeInBits() == 1);
- SmallVector<const Value *, 2> Operands{Op0, Op1};
return TTI.getArithmeticInstrCost(
- match(I, m_LogicalOr()) ? Instruction::Or : Instruction::And, VectorTy,
- CostKind, {Op1VK, Op1VP}, {Op2VK, Op2VP}, Operands, I);
+ match(I, m_LogicalOr()) ? Instruction::Or : Instruction::And,
+ VectorTy, CostKind, {Op1VK, Op1VP}, {Op2VK, Op2VP}, {Op0, Op1}, I);
}
Type *CondTy = SI->getCondition()->getType();
@@ -6425,7 +6424,7 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
}))
continue;
VecValuesToIgnore.insert(Op);
- DeadInterleavePointerOps.append(Op->op_begin(), Op->op_end());
+ append_range(DeadInterleavePointerOps, Op->operands());
}
for (const auto &[_, Ops] : DeadInvariantStoreOps)
@@ -6485,7 +6484,7 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
ValuesToIgnore.insert(Op);
VecValuesToIgnore.insert(Op);
- DeadOps.append(Op->op_begin(), Op->op_end());
+ append_range(DeadOps, Op->operands());
}
// Ignore type-promoting instructions we identified during reduction
@@ -8687,10 +8686,8 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
VPRecipeBase *Recipe =
RecipeBuilder.tryToCreateWidenRecipe(SingleDef, Range);
- if (!Recipe) {
- SmallVector<VPValue *, 4> Operands(R.operands());
- Recipe = RecipeBuilder.handleReplication(Instr, Operands, Range);
- }
+ if (!Recipe)
+ Recipe = RecipeBuilder.handleReplication(Instr, R.operands(), Range);
RecipeBuilder.setRecipe(Instr, Recipe);
if (isa<VPWidenIntOrFpInductionRecipe>(Recipe) && isa<TruncInst>(Instr)) {
More information about the llvm-commits
mailing list