This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][CostModel] Model vrgather.vv as being quadradic in LMUL
ClosedPublic

Authored by reames on Jun 2 2023, 11:42 AM.

Details

Summary

vrgather.vv across multiple vector registers (i.e. LMUL > 1) requires all to all data movement. This includes two conceptual sets of changes:

  • For permutes, we were modeling these as being linear in LMUL.
  • For reverse, we were modeling them as being fixed cost in LMUL.

Noticed via code inspection while looking at something else.

Its worth asking whether we should be lowering reverse to something other than a vrgather at high LMULs. That shuffle is quite expensive.

Diff Detail

Event Timeline

reames created this revision.Jun 2 2023, 11:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 11:42 AM
reames requested review of this revision.Jun 2 2023, 11:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 11:42 AM
reames updated this revision to Diff 528027.Jun 2 2023, 3:43 PM
reames edited the summary of this revision. (Show Details)

Merging a change to model LMUL in reverse shuffles. I'd originally intended to have this be a separate follow up change, but once I wrote it, the abstraction I'd added here no long made sense. So, let's just fix all the vrgather.vv usage in one go.

I think the vrgather.vv for reverse needs at most 2 sources for each VLEN piece. Is it likely hardware would optimize for that?

reames added a comment.Jun 2 2023, 3:48 PM

I think the vrgather.vv for reverse needs at most 2 sources for each VLEN piece. Is it likely hardware would optimize for that?

It's certainly possible. Do you have existence proof in either direction? I'm guessing at the moment.

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

I can't comment on whether the shuffle cost matches hardware, but the code itself LGTM

This revision is now accepted and ready to land.Jul 18 2023, 9:39 AM
This revision was landed with ongoing or failed builds.Jul 18 2023, 11:54 AM
This revision was automatically updated to reflect the committed changes.