This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Teach VSETVLIInserter to not demand tail policy when there is no tail element
Needs RevisionPublic

Authored by jacquesguan on Aug 4 2023, 1:01 AM.

Details

Summary

If avl is vlmax and lmul is not fractional, there is no tail element so that no need to demand tail policy.

Diff Detail

Event Timeline

jacquesguan created this revision.Aug 4 2023, 1:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 1:01 AM
jacquesguan requested review of this revision.Aug 4 2023, 1:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 1:01 AM
luke added inline comments.Aug 4 2023, 2:31 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
380

The VL operand can be stale here because this is called from doLocalPostpass, after the pseudo has been expanded and the vsetvlis are inserted. Is it possible to move this into needVSETVLI?

craig.topper added inline comments.Aug 4 2023, 7:50 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
375

This is incorrect for vcompress, reductions, and vmv.s.x.

Address comment.

jacquesguan marked 2 inline comments as done.Aug 7 2023, 8:34 PM
jacquesguan added inline comments.
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
375

Done, exclude these instructions.

380

Done, moved to needVSETVLI.

jacquesguan marked 2 inline comments as done.

change switch to equal.

craig.topper added inline comments.Aug 7 2023, 8:53 PM
llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll
585

Wouldn't we want ta instead of tu since there is no tail?

Use tail agnostic.

jacquesguan marked an inline comment as done.Aug 8 2023, 12:32 AM
jacquesguan added inline comments.
llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll
585

Done.

craig.topper added inline comments.Aug 8 2023, 4:30 PM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
820

!decodeVLMUL(VLMul).second

973

!decodeVLMUL(VLMul).second

jacquesguan marked an inline comment as done.

Address comment.

jacquesguan marked 2 inline comments as done.Aug 8 2023, 7:57 PM
reames requested changes to this revision.Aug 22 2023, 1:54 PM

Taking a step back from the code, can you say a little about the motivation for this? I don't see anything particularly compelling in the test diffs. Why do you think this is an interesting optimization to implement?

Also, you definitely need more meaningful test coverage before this is reviewable. However, let's start with the motivation as I don't want to waste your time on writing tests if we're going to end up taking a different approach anyways.

This revision now requires changes to proceed.Aug 22 2023, 1:54 PM