This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Record whether scalar IVs are need in induction recipe. (NFC)
ClosedPublic

Authored by fhahn on Jan 25 2022, 11:06 AM.

Details

Summary

This explicitly records whether a scalar IV is needed in the
VPWidenIntOrFpInductionRecipe, to remove a dependence on the cost-model
during its ::execute.

It will also be used in D116123 to determine if a vector phi will be
generated.

Diff Detail

Event Timeline

fhahn created this revision.Jan 25 2022, 11:06 AM
fhahn requested review of this revision.Jan 25 2022, 11:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 11:06 AM
Herald added a subscriber: vkmr. · View Herald Transcript
fhahn updated this revision to Diff 403375.Jan 26 2022, 12:40 PM

Rename to needsVectorIV

fhahn retitled this revision from [VPlan] Record whether scalar IVs are need in induction recipe. to [VPlan] Record whether scalar IVs are need in induction recipe. (NFC).Jan 27 2022, 3:00 AM
Ayal added inline comments.Jan 27 2022, 8:12 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
2585–2586

While we're here, comment above is out of sync with code below.

8600

!NeedsScalarIV || !NeedsScalarIVOnly - suffice to have only !NeedsScalarIVOnly to feed NeedsVectorIV ?

Refactor the code that constructs a VPWidenIntOrFpInductionRecipe to be used by both tryToOptimizeInduction[PHI,Truncate]?

fhahn updated this revision to Diff 403691.Jan 27 2022, 9:10 AM

Address latest comments, thanks! I unified the VPWidenIntOrFpInductionRecipe* creating in a single helper. Comment also updated.

fhahn marked 2 inline comments as done.Jan 27 2022, 9:12 AM
fhahn added inline comments.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
2585–2586

Updated, thanks!

8600

Good point, thanks! Looks like !NeedsScalarIVOnly is indeed sufficient. Updated and also moved to common createInductionRecipe helper!

Ayal accepted this revision.Jan 27 2022, 9:42 AM

This is fine, couple of final nits; thanks for accommodating!

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

Suffice to ask if !Def->needsScalarIV() as that implies Def->needsVectorIV() - they cannot both be false if Def is not dead - but being explicit is clearer?

2595

Suffice to ask if Def->needsVectorIV() as we already know that Def->needsScalarIV() here - but being explicit is clearer?

8525

"create[Widen]InductionRecipe" ?

8547

Nice to see the above encapsulated here!

This revision is now accepted and ready to land.Jan 27 2022, 9:42 AM
fhahn updated this revision to Diff 403917.Jan 28 2022, 1:05 AM
fhahn marked 2 inline comments as done.

Address latest comments, thanks! I am planning to land this soon.

This revision was landed with ongoing or failed builds.Jan 28 2022, 1:34 AM
This revision was automatically updated to reflect the committed changes.