[llvm] [NFC][RISCV] Keep AVLReg define instr inside VSETVLInfo (PR #89180)

Piyou Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 00:21:08 PDT 2024


================
@@ -495,24 +495,29 @@ class VSETVLIInfo {
   void setAVLIgnored() { State = AVLIsIgnored; }
 
   bool hasAVLImm() const { return State == AVLIsImm; }
-  bool hasAVLReg() const { return State == AVLIsReg; }
+  bool hasAVLDefMI() const { return State == AVLIsDefMI; }
   bool hasAVLVLMAX() const { return State == AVLIsVLMAX; }
   bool hasAVLIgnored() const { return State == AVLIsIgnored; }
   Register getAVLReg() const {
-    assert(hasAVLReg());
-    return AVLReg;
+    assert(hasAVLDefMI());
+    return AVLDefMI->getOperand(0).getReg();
----------------
BeMg wrote:

How about keeping both AVLReg and AVLDefMI inside VSETVLInfo? Tracking the operand number looks too indirect because we just want AVLReg here.

`RISCVInsertVSETVLI::insertVSETVLI` is only place need AVLReg actually.

```
  Register AVLReg = Info.getAVLReg();
  MRI->constrainRegClass(AVLReg, &RISCV::GPRNoX0RegClass);
  BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETVLI))
      .addReg(RISCV::X0, RegState::Define | RegState::Dead)
      .addReg(AVLReg)
      .addImm(Info.encodeVTYPE());
```

https://github.com/llvm/llvm-project/pull/89180


More information about the llvm-commits mailing list