This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeTypes][VP] Widen load/store of fixed length vectors to VP ops

Authored by luke on Apr 19 2023, 6:30 AM.



If we have a load/store with an illegal fixed length vector result type that
needs widened, e.g. x:v6i32 = load p
Instead of just widening it to: x:v8i32 = load p
We can widen it to the equivalent VP operation and set the EVL to the
exact number of elements needed: x:v8i32 = vp_load a, b, mask=true, evl=6
Provided that the target supports vp_load/vp_store on the widened type.

Scalable vectors are already widened this way where possible, so this
largely reuses the same logic.

Diff Detail

Event Timeline

luke created this revision.Apr 19 2023, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 6:30 AM
luke requested review of this revision.Apr 19 2023, 6:30 AM

Sorry, dropped the ball on this. The code looks good to me.

I wonder if someone with a better sense of architectural performance can say this is likely to be faster? Fetching/writing less memory must be good, right? On top of that we're doing fewer vector extracts so fewer instructions in general.

I also dropped the ball on this. Will try to review for real after I sleep.

craig.topper added inline comments.Jun 2 2023, 10:02 AM

Can we use SelectionDAG::getElementCount?

luke added a comment.Jun 6 2023, 2:41 AM

No worries, I've also dropped the ball on this too. I've left some comments on the child patch D148523 from the last time I looked at it, and the gist is that I don't think that patch makes as much sense as this one anymore.

luke updated this revision to Diff 528765.Jun 6 2023, 3:10 AM

Rebase and use SelectionDAG::getElementCount

luke added inline comments.Jun 6 2023, 3:15 AM

We lose this optimisation because we're no longer scalarizing the vector loads and stores. Can we add a combine for (store p, (insertelt x, (load p))?

This revision is now accepted and ready to land.Jun 6 2023, 11:20 AM
This revision was landed with ongoing or failed builds.Jun 12 2023, 2:21 AM
This revision was automatically updated to reflect the committed changes.