[llvm] 459c48e - NFCI: Remove VF argument from isScalarWithPredication
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri May 14 02:35:43 PDT 2021
Author: Sander de Smalen
Date: 2021-05-14T10:34:40+01:00
New Revision: 459c48e04f25a40a81e9e11ccb9c17a88dc39999
URL: https://github.com/llvm/llvm-project/commit/459c48e04f25a40a81e9e11ccb9c17a88dc39999
DIFF: https://github.com/llvm/llvm-project/commit/459c48e04f25a40a81e9e11ccb9c17a88dc39999.diff
LOG: NFCI: Remove VF argument from isScalarWithPredication
As discussed in D102437, the VF argument to isScalarWithPredication
seems redundant, so this is intended to be a non-functional change. It
seems wrong to query the widening decision at this point. Removing the
operand and code to get the widening decision causes no unit/regression
tests to fail. I've also found no issues running the LLVM test-suite.
This subsequently removes the VF argument from isPredicatedInst as well,
since it is no longer required.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 7e8114f379642..90343f3a57fa0 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1517,21 +1517,19 @@ class LoopVectorizationCostModel {
/// instructions that may divide by zero.
/// If a non-zero VF has been calculated, we check if I will be scalarized
/// predication for that VF.
- bool
- isScalarWithPredication(Instruction *I,
- ElementCount VF = ElementCount::getFixed(1)) const;
+ bool isScalarWithPredication(Instruction *I) const;
// Returns true if \p I is an instruction that will be predicated either
// through scalar predication or masked load/store or masked gather/scatter.
// Superset of instructions that return true for isScalarWithPredication.
- bool isPredicatedInst(Instruction *I, ElementCount VF) {
+ bool isPredicatedInst(Instruction *I) {
if (!blockNeedsPredication(I->getParent()))
return false;
// Loads and stores that need some form of masked operation are predicated
// instructions.
if (isa<LoadInst>(I) || isa<StoreInst>(I))
return Legal->isMaskRequired(I);
- return isScalarWithPredication(I, VF);
+ return isScalarWithPredication(I);
}
/// Returns true if \p I is a memory instruction with consecutive memory
@@ -5325,8 +5323,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {
Scalars[VF].insert(Worklist.begin(), Worklist.end());
}
-bool LoopVectorizationCostModel::isScalarWithPredication(
- Instruction *I, ElementCount VF) const {
+bool LoopVectorizationCostModel::isScalarWithPredication(Instruction *I) const {
if (!blockNeedsPredication(I->getParent()))
return false;
switch(I->getOpcode()) {
@@ -5338,14 +5335,6 @@ bool LoopVectorizationCostModel::isScalarWithPredication(
return false;
auto *Ptr = getLoadStorePointerOperand(I);
auto *Ty = getMemInstValueType(I);
- // We have already decided how to vectorize this instruction, get that
- // result.
- if (VF.isVector()) {
- InstWidening WideningDecision = getWideningDecision(I, VF);
- assert(WideningDecision != CM_Unknown &&
- "Widening decision should be ready at this moment");
- return WideningDecision == CM_Scalarize;
- }
const Align Alignment = getLoadStoreAlignment(I);
return isa<LoadInst>(I) ? !(isLegalMaskedLoad(Ty, Ptr, Alignment) ||
isLegalMaskedGather(Ty, Alignment))
@@ -5463,7 +5452,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
<< *I << "\n");
return;
}
- if (isScalarWithPredication(I, VF)) {
+ if (isScalarWithPredication(I)) {
LLVM_DEBUG(dbgs() << "LV: Found not uniform being ScalarWithPredication: "
<< *I << "\n");
return;
@@ -6682,7 +6671,7 @@ bool LoopVectorizationCostModel::useEmulatedMaskMemRefHack(Instruction *I){
// from moving "masked load/store" check from legality to cost model.
// Masked Load/Gather emulation was previously never allowed.
// Limited number of Masked Store/Scatter emulation was allowed.
- assert(isPredicatedInst(I, ElementCount::getFixed(1)) &&
+ assert(isPredicatedInst(I) &&
"Expecting a scalar emulated instruction");
return isa<LoadInst>(I) ||
(isa<StoreInst>(I) &&
@@ -6955,7 +6944,7 @@ LoopVectorizationCostModel::getMemInstScalarizationCost(Instruction *I,
// If we have a predicated load/store, it will need extra i1 extracts and
// conditional branches, but may not be executed for each vector lane. Scale
// the cost by the probability of executing the predicated block.
- if (isPredicatedInst(I, ElementCount::getFixed(1))) {
+ if (isPredicatedInst(I)) {
Cost /= getReciprocalPredBlockProb();
// Add the cost of an i1 extract and a branch
@@ -8716,9 +8705,7 @@ VPWidenCallRecipe *VPRecipeBuilder::tryToWidenCall(CallInst *CI,
VFRange &Range) const {
bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
- [this, CI](ElementCount VF) {
- return CM.isScalarWithPredication(CI, VF);
- },
+ [this, CI](ElementCount VF) { return CM.isScalarWithPredication(CI); },
Range);
if (IsPredicated)
@@ -8760,8 +8747,7 @@ bool VPRecipeBuilder::shouldWiden(Instruction *I, VFRange &Range) const {
// scalarization is profitable or it is predicated.
auto WillScalarize = [this, I](ElementCount VF) -> bool {
return CM.isScalarAfterVectorization(I, VF) ||
- CM.isProfitableToScalarize(I, VF) ||
- CM.isScalarWithPredication(I, VF);
+ CM.isProfitableToScalarize(I, VF) || CM.isScalarWithPredication(I);
};
return !LoopVectorizationPlanner::getDecisionAndClampRange(WillScalarize,
Range);
@@ -8835,7 +8821,7 @@ VPBasicBlock *VPRecipeBuilder::handleReplication(
Range);
bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
- [&](ElementCount VF) { return CM.isPredicatedInst(I, VF); }, Range);
+ [&](ElementCount VF) { return CM.isPredicatedInst(I); }, Range);
auto *Recipe = new VPReplicateRecipe(I, Plan->mapToVPValues(I->operands()),
IsUniform, IsPredicated);
More information about the llvm-commits
mailing list