[PATCH] D111303: [LV] Expand VPIntOrFpInductionRecipe steps up front.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 7 04:41:47 PDT 2021


fhahn created this revision.
fhahn added reviewers: Ayal, gilr.
Herald added subscribers: rogfer01, javed.absar, bollu, hiraditya.
fhahn requested review of this revision.
Herald added a subscriber: vkmr.
Herald added a project: LLVM.

SCEV expansion requires LI & DT to be up-to-date for correctness. It
also expects no changes in the IR that may impact SCEV.

At the moment, LV's use of SCEV can violate those pre-conditions. The
induction step's SCEV expressions are currently expanded during code
generation. At this point, the dominator tree may not be up-to-date and
there may be signification IR changes.

Those issues cause a crash exposed by D71539 <https://reviews.llvm.org/D71539> and caused a recent revert
(1fbdbb559569 <https://reviews.llvm.org/rG1fbdbb559569641f6d509b569966901c8fb02b63>).

This patch is a first step towards removing any SCEV expansion from
VPlan code generation. Instead of expanding induction steps during
recipe execution, the steps are expanded before VPlan code generation.

VPWidenIntOrFpInductionRecipe is extended by a VPValue representing the
step. The induction descriptor is also added. At the beginning of VPlan
execution the induction step is expanded. At this stage, the domintor
tree should still be up-to-date. The existing step VPValue is then
replaced by a new live-in VPValue with the expanded step value.

Alternatively we could also keep the induction recipe as 'incomplete'
and only add the concrete step value after expansion.

This patch only updates the code that executes
VPWidenIntOrFpInductionRecipes to use the step value. For all other
instances it still expands the step SCEV on the fly. This is to keep the
patch manageable. The other instances require followup work, including

1. possibly moving pointer induction handling out of the general

VPWidenPHIRecipe and 2) updating fixupIVUsers to operate on induction
recipes.

The change to move InductionDescriptor to VPWidenIntOrFpInductionRecipe
could also be separate out, if desired.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111303

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
  llvm/lib/Transforms/Vectorize/VPlan.cpp
  llvm/lib/Transforms/Vectorize/VPlan.h
  llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111303.377805.patch
Type: text/x-patch
Size: 22787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211007/dd642a88/attachment.bin>


More information about the llvm-commits mailing list