[PATCH] D77972: [VPlan] Move Load/Store checks out of tryToWiden (NFC).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 12 08:00:11 PDT 2020


fhahn created this revision.
fhahn added reviewers: gilr, rengolin, Ayal, hsaito.
Herald added subscribers: psnobl, rogfer01, rkruppe, tschuett, bollu, hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77972

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp


Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6987,7 +6987,6 @@
     case Instruction::FSub:
     case Instruction::ICmp:
     case Instruction::IntToPtr:
-    case Instruction::Load:
     case Instruction::LShr:
     case Instruction::Mul:
     case Instruction::Or:
@@ -6999,7 +6998,6 @@
     case Instruction::Shl:
     case Instruction::SIToFP:
     case Instruction::SRem:
-    case Instruction::Store:
     case Instruction::Sub:
     case Instruction::Trunc:
     case Instruction::UDiv:
@@ -7019,12 +7017,6 @@
     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;
   };
 
@@ -7049,6 +7041,23 @@
   bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
       [&](unsigned VF) { return CM.isScalarWithPredication(I, VF); }, Range);
 
+  // Make sure only memory instructions explicitly marked or profitable with
+  // scalarization are handled with replication. Otherwise they should have been
+  // widened earlier.
+  assert(
+      IsPredicated ||
+      LoopVectorizationPlanner::getDecisionAndClampRange(
+          [this, I](unsigned VF) {
+            if (VF == 1 || (!isa<LoadInst>(I) && !isa<StoreInst>(I)))
+              return true;
+            return CM.isProfitableToScalarize(I, VF) ||
+                   CM.isScalarAfterVectorization(I, VF) ||
+                   CM.getWideningDecision(I, VF) ==
+                       LoopVectorizationCostModel::CM_Scalarize;
+          },
+          Range) &&
+          "Memory widening decisions should have been taken care of by now.");
+
   auto *Recipe = new VPReplicateRecipe(I, IsUniform, IsPredicated);
   setRecipe(I, Recipe);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77972.256857.patch
Type: text/x-patch
Size: 2191 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200412/7fb48c74/attachment.bin>


More information about the llvm-commits mailing list