[llvm] [RISCVInsertVSETVLI] Allow PRE with non-immediate AVLs (PR #71728)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 19:18:41 PST 2023
================
@@ -1364,9 +1341,21 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
if (UnavailablePred->succ_size() != 1)
return;
- // If VL can be less than AVL, then we can't reduce the frequency of exec.
- if (!willVLBeAVL(AvailableInfo, *ST))
- return;
+ // If the AVL value is a register (other than our VLMAX sentinel),
+ // we need to prove the value is available at the point we're going
+ // to insert the vsetvli at.
+ if (AvailableInfo.hasAVLReg() && RISCV::X0 != AvailableInfo.getAVLReg()) {
+ MachineInstr *AVLDefMI = MRI->getVRegDef(AvailableInfo.getAVLReg());
+ if (!AVLDefMI)
+ return;
+ // This is an inline dominance check which covers the case of
+ // UnavailablePrede being the preheader of a loop.
----------------
lukel97 wrote:
```suggestion
// UnavailablePred being the preheader of a loop.
```
https://github.com/llvm/llvm-project/pull/71728
More information about the llvm-commits
mailing list