[PATCH] D121617: [LV] Move code to place induction increment to VPlan post-processing.

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 20 14:32:59 PDT 2022


Ayal added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9533
+  // Add induction update using an incorrect block temporarily. The phi node
+  // will be fixed after VPlan execution.
+  VecInd->addIncoming(LastInduction, State.CFG.VectorPreHeader);
----------------
This goes back to D22416.
Simply adding this last step here with its current block, as done prior to D22416, may be incorrect - when header and latch are distinct due to replicated regions? (May be good to (have a) test)

Would be good to explain that the last induction step, which feeds PHI, cannot be added yet to PHI properly, because that requires the latch block - which may not have been formed yet. An alternative to an incorrect addIncoming() may be to record LastInduction temporarily inside its VPWidenIntOrFpInductionRecipe (as it's operand(?) - see below), until it can be added to PHI properly. Given that LastInduction is eventually placed in the latch, another alternative may be to designate a recipe for generating LastInduction, placing it in the latch, so that when the recipe executes it could add LastInduction properly to PHI. Listing these alternatives mainly for the sake of completeness...


================
Comment at: llvm/lib/Transforms/Vectorize/VPlan.cpp:990
 
+    // Set the correct incoming block for backedge values and move induction to
+    // latch.
----------------
Could the incoming value to an induction be added similar to adding such values for reductions and FORs below, which have distinct values across the backedge? I.e., another case of SinglePartNeeded? Could PhiR->getBackedgeValue() work - if the induction PhiR is added as an (second) operand of itself?

Moving the last induction step to the end of the latch could then be done separately.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121617/new/

https://reviews.llvm.org/D121617



More information about the llvm-commits mailing list