This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Implement getVScaleForTuning and thus prefer scalable vectorization when enabled
ClosedPublic

Authored by reames on Jun 24 2022, 11:54 AM.

Details

Summary

LoopVectorizer uses getVScaleForTuning for deciding how to discount the cost of a potential vector factor by the amount of work performed. Without the callback implemented, the vectorizer was defaulting to an estimated vscale of 1. This results in fixed vectorization looking falsely profitable (since it used the command line VLEN).

The test change is pretty limited since a) we don't have much coverage of the vectorizer with scalable vectors at all, and b) what little coverage we have mostly uses i64 element types. There's a separate issue with <vscale x 1 x i64> which prevents us from getting to this stage of costing, and thus only the one test explicitly written to avoid that is visible in the diff. However, this is actually a very wide impact change as it changes the practical vectorization result when both fixed and scalable is enabled to scalable.

As an aside, I think the vectorizer is at little too strongly biased towards scalable when both are legal, but we can explore that separately. For now, let's just get the cost model working the way it was intended.

Diff Detail

Event Timeline

reames created this revision.Jun 24 2022, 11:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 11:54 AM
reames requested review of this revision.Jun 24 2022, 11:54 AM
This revision is now accepted and ready to land.Jun 24 2022, 11:19 PM
This revision was landed with ongoing or failed builds.Jun 25 2022, 11:25 AM
This revision was automatically updated to reflect the committed changes.