This is an archive of the discontinued LLVM Phabricator instance.

[clang][RISCV] Set vscale_range attribute based on presence of "v" extension
ClosedPublic

Authored by reames on Oct 13 2022, 10:30 AM.

Details

Summary

This follows the path that AArch64 SVE has taken. Doing this via a function attribute set in the frontend is basically a workaround for the fact that several analyzes which need the information (i.e. known bits, lvi, scev) can't easily use TTI without significant amounts of plumbing changes.

This patch hard codes "v" numbers, and directly follows the SVE precedent as a result. In a follow up, I hope to drive this from RISCVISAInfo.h/cpp instead, but the MinVLen number being returned from that interface seemed to always be 0 (which is wrong), and I haven't figured out what's going wrong there.

Diff Detail

Event Timeline

reames created this revision.Oct 13 2022, 10:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 10:30 AM
reames requested review of this revision.Oct 13 2022, 10:30 AM

There's also this patch from @frasercrmck https://reviews.llvm.org/D107290

So there is; had not seen that. Looking at it, that patch seems to roll several items together. I'd strongly prefer if we worked incrementally here. I think we do need to merge the frontend and backend handling here, but we can we work one step at a time?

Steps as I currently see them:
Step 1 - get basic support for "v", to unblock practical codegen
Step 2 - expose the necessary constants for frontend use, and rephrase in terms of VLEN
Step 3 - figure out why getMinVLen on RISCVISAInfo is currently always returning 0, fix that
Step 4 - revisit question if whether the result replaces TTI callback (I don't think it does, but don't want to speculate too much now.)

I'm willing to commit my time through at least step 3, and possibly beyond.

Matt added a subscriber: Matt.Oct 13 2022, 10:58 AM
craig.topper added inline comments.Oct 17 2022, 9:39 AM
clang/lib/Basic/Targets/RISCV.cpp
256

Minimum

reames updated this revision to Diff 468239.Oct 17 2022, 9:52 AM

fix typo

This revision is now accepted and ready to land.Oct 17 2022, 10:07 AM