[llvm] 79d185c - [VPlan] Move Load/Store checks out of tryToWiden (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 02:23:43 PDT 2020


Author: Florian Hahn
Date: 2020-04-15T10:18:42+01:00
New Revision: 79d185c79271455c6b05c86ba422f40e70c7e970

URL: https://github.com/llvm/llvm-project/commit/79d185c79271455c6b05c86ba422f40e70c7e970
DIFF: https://github.com/llvm/llvm-project/commit/79d185c79271455c6b05c86ba422f40e70c7e970.diff

LOG: [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

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 31c8ffcb7fd9..1ef5e059644d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6961,6 +6961,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
   if (IsPredicated)
     return nullptr;
 
+  assert(!isa<PHINode>(I) && "PHIs should have been handled earlier");
   auto IsVectorizableOpcode = [](unsigned Opcode) {
     switch (Opcode) {
     case Instruction::Add:
@@ -6981,11 +6982,9 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
     case Instruction::FSub:
     case Instruction::ICmp:
     case Instruction::IntToPtr:
-    case Instruction::Load:
     case Instruction::LShr:
     case Instruction::Mul:
     case Instruction::Or:
-    case Instruction::PHI:
     case Instruction::PtrToInt:
     case Instruction::SDiv:
     case Instruction::Select:
@@ -6993,7 +6992,6 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
     case Instruction::Shl:
     case Instruction::SIToFP:
     case Instruction::SRem:
-    case Instruction::Store:
     case Instruction::Sub:
     case Instruction::Trunc:
     case Instruction::UDiv:
@@ -7010,16 +7008,8 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
     return nullptr;
 
   auto willWiden = [&](unsigned VF) -> bool {
-    if (!isa<PHINode>(I) && (CM.isScalarAfterVectorization(I, VF) ||
-                             CM.isProfitableToScalarize(I, VF)))
-      return false;
-    if (isa<LoadInst>(I) || isa<StoreInst>(I)) {
-      assert(CM.getWideningDecision(I, VF) ==
-                 LoopVectorizationCostModel::CM_Scalarize &&
-             "Memory widening decisions should have been taken care by now");
-      return false;
-    }
-    return true;
+    return !CM.isScalarAfterVectorization(I, VF) &&
+           !CM.isProfitableToScalarize(I, VF);
   };
 
   if (!LoopVectorizationPlanner::getDecisionAndClampRange(willWiden, Range))


        


More information about the llvm-commits mailing list