Revert "Recommit "[VPlan] Remove uneeded needsVectorIV check.""
authorFlorian Hahn <flo@fhahn.com>
Mon, 9 May 2022 19:33:14 +0000 (20:33 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 9 May 2022 19:33:14 +0000 (20:33 +0100)
This reverts commit 8b48223447311af8b3022697dd58858e1ce6975f.

This triggers an assertion on a test case mentioned in D123720.
Revert while I investigate.

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

index e8f2e2f..f4d2af2 100644 (file)
@@ -429,8 +429,15 @@ void VPlanTransforms::optimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
         IV->getStartValue(), Step, TruncI ? TruncI->getType() : nullptr);
     HeaderVPBB->insert(Steps, HeaderVPBB->getFirstNonPhi());
 
-    // Update scalar users of IV to use Step instead. Use SetVector to ensure
-    // the list of users doesn't contain duplicates.
+    // If there are no vector users of IV, simply update all users to use Step
+    // instead.
+    if (!IV->needsVectorIV()) {
+      IV->replaceAllUsesWith(Steps);
+      continue;
+    }
+
+    // Otherwise only update scalar users of IV to use Step instead. Use
+    // SetVector to ensure the list of users doesn't contain duplicates.
     SetVector<VPUser *> Users(IV->user_begin(), IV->user_end());
     for (VPUser *U : Users) {
       VPRecipeBase *R = cast<VPRecipeBase>(U);