This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][InsertVSETVLI] Treat vmv.v.i as-if it were vmv.s.x when VL=1, and inactive lanes are undefined
ClosedPublic

Authored by reames on Jun 13 2023, 11:24 AM.

Details

Summary

This is an alternative to D151653. It's based on that code, just slightly cleaned up.

A vmv.v.i/x splats the immediate to all active lanes. For the active lanes, this is the same as vmv.s.x which inserts one scalar into the low lane. If we can ignore all the inactive lanes (because they are known undefined), then the two are semantically equivalent. We already reason about compatible VL/VTYPE combinations for vmv.s.x, apply the same logic to vmv.v.i.

Unlike a vmv.s.x, we do need to be careful not to increase LMUL. A splat instruction is probably linear in LMUL, so restrict this to LMUL1.

Diff Detail

Event Timeline

reames created this revision.Jun 13 2023, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 11:24 AM
reames requested review of this revision.Jun 13 2023, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 11:24 AM
reames planned changes to this revision.Jun 13 2023, 11:33 AM

Forgot to guard against LMUL increase, and we can handle vmv.v.x, and fvmv.v.f at the same time. Update pending.

reames updated this revision to Diff 531010.Jun 13 2023, 11:37 AM
reames edited the summary of this revision. (Show Details)

Don't increase LMUL, move to forward pass only (for now), and handle vmv.v.x, and vfmv.v.f.

luke added a comment.Jun 14 2023, 1:26 AM

Is it possible to move this into getDemanded so that it’s also used by the bottom-to-top pass in phase 3? Otherwise this won’t catch cases that are at the start of blocks with no successors, e.g. the vmv.v.i is the first instruction of the function.

luke accepted this revision.Jun 14 2023, 1:18 PM

LGTM

This revision is now accepted and ready to land.Jun 14 2023, 1:18 PM
This revision was landed with ongoing or failed builds.Jun 15 2023, 2:10 PM
This revision was automatically updated to reflect the committed changes.