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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 00:32:31 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();
----------------
lukel97 wrote:

Yeah that also works, as long as we can fit it inside the existing union, something like this maybe?

```c++
  struct Def { const MachineInstr *DefMI; Register Reg; };
  union {
    Def AVLDef;
    unsigned AVLImm;
  };
```

Would need to also update the == and AVL comparison methods to check the register too I think

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


More information about the llvm-commits mailing list