This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Avoid reducing etype just to initialize lane 0 of an undef vector
ClosedPublic

Authored by reames on Jun 15 2022, 10:27 AM.

Details

Summary

If we're writing to an undef vector (i.e. implicit_def), we can change the value of bits outside the requested write without consequence. This allows us to avoid a VSETVLI just for narrowing the value written.

Diff Detail

Event Timeline

reames created this revision.Jun 15 2022, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 10:27 AM
reames requested review of this revision.Jun 15 2022, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 10:27 AM
craig.topper accepted this revision.Jun 15 2022, 5:02 PM

LGTM other than the comment about elideCopies.

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1026

I wonder if we should call elideCopies here like we do when we look for implicit def for tail policy.

This revision is now accepted and ready to land.Jun 15 2022, 5:02 PM
craig.topper added inline comments.Jun 15 2022, 8:15 PM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1026

Hmm it doesn't look like any existing lit tests need the elideCopies call in other location. So I'm not sure if that's still needed. It might be a left over from when we did vsetvli insertion right after SelectionDAG.

reames added inline comments.Jun 16 2022, 10:55 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1026

I'm going to take a closer look at this separately, and probably post a patch removing the copy handling.

This revision was landed with ongoing or failed builds.Jun 16 2022, 11:14 AM
This revision was automatically updated to reflect the committed changes.
reames added inline comments.Jun 16 2022, 11:27 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1026