This is an archive of the discontinued LLVM Phabricator instance.

[LV] Move all VPlan transforms after initial VPlan construction.
ClosedPublic

Authored by fhahn on Jul 6 2023, 12:16 PM.

Details

Summary

Reorder VPlan transforms slightly so they are all grouped together,
after disabling Value -> VPValue lookup. In terms of codegen impact,
this should be NFC modulo a small number of instruction reorderings.

Preparation to split up tryToBuildVPlanWithVPRecipes in a follow-up.

Diff Detail

Event Timeline

fhahn created this revision.Jul 6 2023, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 12:16 PM
fhahn requested review of this revision.Jul 6 2023, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 12:16 PM
Herald added subscribers: wangpc, vkmr. · View Herald Transcript
fhahn retitled this revision from [LV] Move all VPlan transforms after initial VPlan construction (NFC). to [LV] Move all VPlan transforms after initial VPlan construction..Jul 6 2023, 12:23 PM
fhahn edited the summary of this revision. (Show Details)
Ayal accepted this revision.Jul 15 2023, 1:19 PM

This looks good to me, with some thoughts of possible follow-up...

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
9058

(Possible follow-up:) Could adjustRecipesForReductions() be refactored to walk the def-use chains of recipes rather than rely on retrieving recipes of recorded Instructions, so it could (continue to) be next to adjust[RecipesFor]FixedOrderRecurrences()? The latter part of adjustRecipesForReductions() which introduces selects in case of fold-tail is already Value2VPValue-free.

The call to RecipeBuilder.fixHeaderPhis() should indeed be part of the initial VPlan construction as it completes the def-use relations of reduction and FOR header phi's, using Value2VPValue. Still, it too could walk header phi recipes instead of relying on the recorded PhisToFix?

9122

This doesn't use Value2VPValue mapping directly, but rather searches for a recipe whose underlying value is equal to an Instruction of the recorded getCastInsts...

This revision is now accepted and ready to land.Jul 15 2023, 1:19 PM
fhahn added inline comments.Jul 20 2023, 7:43 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
9058

Updated adjustRecipesForReductions to walk VPlan def-use chains when adjusting in loop reductions in D155845