This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Teach VSETVLI insertion to look through PHIs to prove we don't need to insert a vsetvli.
ClosedPublic

Authored by craig.topper on May 27 2021, 12:42 PM.

Details

Summary

If an instruction's AVL operand is a PHI node in the same block,
we may be able to peek through the PHI to find vsetvli instructions
that produce the AVL in other basic blocks. If we can prove those
vsetvli instructions have the same VTYPE and were the last vsetvli
in their respective blocks, then we don't need to insert a vsetvli
for this pseudo instruction.

Diff Detail

Event Timeline

craig.topper created this revision.May 27 2021, 12:42 PM
craig.topper requested review of this revision.May 27 2021, 12:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2021, 12:42 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
rogfer01 accepted this revision.May 27 2021, 2:30 PM

LGTM. Thanks @craig.topper

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

Just curious here: do you foresee this might get expensive or this is a debugging utility?

This revision is now accepted and ready to land.May 27 2021, 2:30 PM
craig.topper added inline comments.May 27 2021, 2:44 PM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
36

Paranoia. Combining phis and data flow made me a little nervous. Our earlier internal version of this in the EPIRemoveRedundantVSETVLGlobal pass was missing the check that the phi was in the same basic block. A miscompile from it was found months later.

I wonder if we should also have a disable on the global cross BB code. I think EPIRemoveRedundantVSETVLGlobal has a disable right?