RISCVInsertVSETVLI doLocalPass

Hi, I have a question about the RISCVInsertVSETVLI pass.

In the doLocalPass, we can remove the subsequent vsetvl instruction if the preceding one can be mutated to match MI without changing any of the fields that would be observed.

However, what happens if there is a call or something that can change the vtype in between these two instructions?

I see that !isVLPreservingConfig could return false in canMutatePriorConfig, (llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp at main · llvm/llvm-project · GitHub) but what if the MI is a preserving instruction, yet the vtypes are different between the two vsetvl instructions?

1 Like

Hi, if there is a call then in getDemanded both VL and VTYPE will be marked as used completely. That will get unioned into Used, so when we eventually encounter another vsetvli and check canMutatePriorConfig everything should be marked as used in Used.

canMutatePriorConfig will then call areCompatibleVTYPEs and because every VTYPE field in Used is marked as used, it will only return true if the VTYPEs exactly match.

Hope that makes sense!

It does!!!. Thanks!