[llvm] LoopVectorize: guard marking iv as scalar; fix bug (PR #88730)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 03:19:44 PDT 2024


================
@@ -3875,6 +3875,13 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {
     if (!ScalarInd)
       continue;
 
+    // If the induction variable update is a fixed-order recurrence, neither the
+    // induction variable or its update should be marked scalar after
+    // vectorization.
+    auto *IndUpdatePhi = dyn_cast<PHINode>(IndUpdate);
+    if (IndUpdatePhi && Legal->isFixedOrderRecurrence(IndUpdatePhi))
----------------
david-arm wrote:

OK, thanks for taking the time to explain! In this case, is it possible for `Ind` to be a fixed-order recurrence? Just trying to make sure this is a complete fix that's all.

https://github.com/llvm/llvm-project/pull/88730


More information about the llvm-commits mailing list