This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Combine extract_vector_elt followed by VFMV_S_F_VL.
ClosedPublic

Authored by craig.topper on Jan 20 2023, 4:15 PM.

Details

Summary

If we're extracting an element and inserting into a undef vector
with the same number of elements, we can use the original vector.

This pattern occurs around reductions that have been cascaded
together.

This can be generalized to wider/narrow vectors by using
insert_subvector/extract_subvector, but we don't have lit tests
for that case currently.

We can also support non-undef before by using a slide or vmv.v.v

Diff Detail

Event Timeline

craig.topper created this revision.Jan 20 2023, 4:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 4:15 PM
craig.topper requested review of this revision.Jan 20 2023, 4:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 4:15 PM
luke added inline comments.Jan 24 2023, 8:09 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10580

Do we need to handle the case when VL=0 and the destination register is preserved?

reames accepted this revision.Jan 24 2023, 8:57 AM

LGTM

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10580

We checked the passthru result was undef above, so if VL=0 the result is fully undef.

This revision is now accepted and ready to land.Jan 24 2023, 8:57 AM
This revision was landed with ongoing or failed builds.Jan 24 2023, 5:16 PM
This revision was automatically updated to reflect the committed changes.