This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Mark vsadd(u)_vl as commutable
ClosedPublic

Authored by reames on Jul 7 2022, 9:18 AM.

Details

Summary

This allows fixed length vectors involving splats on the LHS to commute into the _vx form of the instruction. Oddly, the generic canonicalization rules appear to catch the scalable vector cases. I haven't fully dug in to understand why, but I suspect it's because of a difference in how we represent splats (splat_vector vs build_vector).

Diff Detail

Event Timeline

reames created this revision.Jul 7 2022, 9:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2022, 9:18 AM
reames requested review of this revision.Jul 7 2022, 9:18 AM
This revision is now accepted and ready to land.Jul 7 2022, 1:50 PM
This revision was automatically updated to reflect the committed changes.

I haven't fully dug in to understand why, but I suspect it's because of a difference in how we represent splats (splat_vector vs build_vector).

To close this. I believe it's because fixed vector uses build_vector of constants for the "step vector" while scalable vector uses the step_vector ISD node. The build_vector being all constants is canonicalized to the RHS. For the step_vector case there is no canonicalization preference so it keeps the order the node was created with which had the splat on the RHS.