Skip to content

Commit 79d185c

Browse files
committed
[VPlan] Move Load/Store checks out of tryToWiden (NFC).
Handling LoadInst and StoreInst in tryToWiden seems a bit counter-intuitive, as there is only an assertion for them and in no case VPWidenRefipes are created for them. I think it makes sense to move the assertion to handleReplication, where the non-widened loads and store are handled. Reviewers: gilr, rengolin, Ayal, hsaito Reviewed By: Ayal Differential Revision: https://reviews.llvm.org/D77972
1 parent 129cf84 commit 79d185c

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6961,6 +6961,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
69616961
if (IsPredicated)
69626962
return nullptr;
69636963

6964+
assert(!isa<PHINode>(I) && "PHIs should have been handled earlier");
69646965
auto IsVectorizableOpcode = [](unsigned Opcode) {
69656966
switch (Opcode) {
69666967
case Instruction::Add:
@@ -6981,19 +6982,16 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
69816982
case Instruction::FSub:
69826983
case Instruction::ICmp:
69836984
case Instruction::IntToPtr:
6984-
case Instruction::Load:
69856985
case Instruction::LShr:
69866986
case Instruction::Mul:
69876987
case Instruction::Or:
6988-
case Instruction::PHI:
69896988
case Instruction::PtrToInt:
69906989
case Instruction::SDiv:
69916990
case Instruction::Select:
69926991
case Instruction::SExt:
69936992
case Instruction::Shl:
69946993
case Instruction::SIToFP:
69956994
case Instruction::SRem:
6996-
case Instruction::Store:
69976995
case Instruction::Sub:
69986996
case Instruction::Trunc:
69996997
case Instruction::UDiv:
@@ -7010,16 +7008,8 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
70107008
return nullptr;
70117009

70127010
auto willWiden = [&](unsigned VF) -> bool {
7013-
if (!isa<PHINode>(I) && (CM.isScalarAfterVectorization(I, VF) ||
7014-
CM.isProfitableToScalarize(I, VF)))
7015-
return false;
7016-
if (isa<LoadInst>(I) || isa<StoreInst>(I)) {
7017-
assert(CM.getWideningDecision(I, VF) ==
7018-
LoopVectorizationCostModel::CM_Scalarize &&
7019-
"Memory widening decisions should have been taken care by now");
7020-
return false;
7021-
}
7022-
return true;
7011+
return !CM.isScalarAfterVectorization(I, VF) &&
7012+
!CM.isProfitableToScalarize(I, VF);
70237013
};
70247014

70257015
if (!LoopVectorizationPlanner::getDecisionAndClampRange(willWiden, Range))

0 commit comments

Comments
 (0)