This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][InsertVSETVLI] Handle partially transparent instructions in PRE
ClosedPublic

Authored by reames on Jan 23 2023, 3:01 PM.

Details

Summary

The PRE implementation was being overly strict when checking to see if a vsetvli was removed in the current block. For instructions which don't use all the fields of VTYPE or VL, we can propagate a changed state past the first instruction with an SEW operand and remove a vsetvli later in the block. We do need to be careful now to ensure that the state convergences before the end of the block or we'd invalidate the cached data flow results.

Taking a step back, we're modeling the effect of the emitVSETVLIs pass which runs just after PRE. This is unfortunate, and makes me think we should probably reevaluate doing the PRE as a post-pass instead of as surgery in the data flow phases. Doing that requires us to get more aggressive about mutating user written vsetvlis which we've tried not to do up to now, but well, maybe it's time? Anyways, that's a thought for the future, not something I'm proposing doing now.

Diff Detail

Event Timeline

reames created this revision.Jan 23 2023, 3:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2023, 3:01 PM
reames requested review of this revision.Jan 23 2023, 3:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2023, 3:01 PM
craig.topper added inline comments.Jan 24 2023, 5:52 PM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1197

vesetvli -> vsetvli

1201

Why int64_t as opposed to int?

llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
956–957

opportunity*

reames updated this revision to Diff 492101.Jan 25 2023, 7:20 AM

Address review comments

reames added inline comments.Jan 25 2023, 7:21 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1201

What's the largest number of instructions a basic block can hold? Is it bounded by an i31? It probably is in all practical term, but int64_t felt "safer".

craig.topper added inline comments.Jan 25 2023, 9:32 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1201

I'd imagine you'd run out of virtual register numbers before you got past i31. Unless you had a lot of instructions that didn't write a register.

This revision is now accepted and ready to land.Jan 25 2023, 5:29 PM
This revision was landed with ongoing or failed builds.Jan 27 2023, 11:52 AM
This revision was automatically updated to reflect the committed changes.