This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Pre-process FP SPLAT_VECTOR to RISCVISD::VFMV_V_F_VL
ClosedPublic

Authored by frasercrmck on Jan 19 2022, 6:10 AM.

Details

Summary

This patch builds on top of D119197 to canonicalize floating-point
SPLAT_VECTOR as RISCVISD::VFMV_V_F_VL as a pre-process ISel step.

This primarily benefits scalable-vector VP code, where our VP patterns
only match VFMV_V_F_VL to reduce the burden on our ISel patterns, but
where at the same time, scalable-vector code doesn't custom-legalize
SPLAT_VECTOR.

Diff Detail

Event Timeline

frasercrmck created this revision.Jan 19 2022, 6:10 AM
frasercrmck requested review of this revision.Jan 19 2022, 6:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2022, 6:10 AM

reformat ComplexPattern to 80 cols

frasercrmck added inline comments.Jan 19 2022, 6:15 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
297

There's still one use of this to match VSELECT_VL with fpimm0. Is there a way to use SplatFPPat but ensure it matches only fpimm0? Must it be its own ComplexPattern?

craig.topper added inline comments.Jan 19 2022, 2:31 PM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
297

I can't think of any way to do it. You could inline this into the one use and add the second pattern for the other case. Then we don't have a single use complex pattern. That's a larger generated table size for two patterns for every FP type, but maybe a drop in the bucket compared to the size of the whole table.

frasercrmck added inline comments.Jan 27 2022, 6:44 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
297

Just so I'm sure, your comment about a larger generated table size applies only to this fpimm0 section because we'd have two riscv_vselect_vl patterns with splat_vector and riscv_vfmv_v_f_vl? The use of the new ComplexPattern elsewhere doesn't increase the table size, unless it's a root?

If that's the case, yeah it's a definitely a shame but perhaps not a big deal, as you say. I can check the differences.

A thought occurs - how feasible is it to preprocess the DAG to turn floating-point splat_vectors into riscv_vfmv_v_f_vl? Then we just need the one pattern everywhere. I'm assuming we don't want to do custom lowering or else we'd already be doing it.

craig.topper added inline comments.Feb 8 2022, 10:22 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
301

The bracket list is only needed if this is used a root node.

pre-process FP splats to VFMV_V_F_VL ala D119197.

frasercrmck retitled this revision from [RISCV] Support matching 'VF' VL patterns via SPLAT_VECTOR to [RISCV] Pre-process FP SPLAT_VECTOR to RISCVISD::VFMV_V_F_VL.Feb 9 2022, 4:45 AM
frasercrmck edited the summary of this revision. (Show Details)

I've just reworked this to build on top of D119197 so no ComplexPattern, no increase in table size, and still the same benefits for scalable-vector VP code.

This revision is now accepted and ready to land.Feb 9 2022, 11:00 AM
This revision was landed with ongoing or failed builds.Feb 10 2022, 2:07 AM
This revision was automatically updated to reflect the committed changes.