[llvm] [RISCV] Move RISCVInsertVSETVLI to after phi elimination (PR #91440)

Piyou Chen via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 22:51:34 PDT 2024


================
@@ -1155,8 +1155,8 @@ define void @mulhu_v8i16(ptr %x) {
 ; CHECK-NEXT:    vle16.v v8, (a0)
 ; CHECK-NEXT:    vmv.v.i v9, 0
 ; CHECK-NEXT:    lui a1, 1048568
-; CHECK-NEXT:    vsetvli zero, zero, e16, m1, tu, ma
 ; CHECK-NEXT:    vmv.v.i v10, 0
----------------
BeMg wrote:

The difference in this test case is caused by the twoaddr pass splitting the `PseudoVMV_S_X` into two pseudo-instructions. However, the first pseudo-instruction lacks the SEW for the vsetvli pass to recognize and emit the appropriate vsetvl instruction.

After the two addr pass

```
%4:vr = PseudoVMV_S_X %2:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype
-> 
%4:vr = COPY %2:vr
%4:vr = PseudoVMV_S_X %4:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype
```

After Post-RA pseudo instruction expansion

```
renamable $v10 = COPY renamable $v9
-> 
$v10 = PseudoVMV_V_I_M1 undef $v10(tied-def 0), 0, 8, 4, 0, implicit $vl, implicit $vtype
```

---

vsetvl insert before twoaddr

```

%4:vr = PseudoVMV_S_X %2:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype

-> vsetvl insertion 

dead $x0 = PseudoVSETVLIX0 killed $x0, 136, implicit-def $vl, implicit-def $vtype, implicit $vl
%4:vr = PseudoVMV_S_X %2:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype

-> two-addr

dead $x0 = PseudoVSETVLIX0 killed $x0, 136, implicit-def $vl, implicit-def $vtype, implicit $vl
%4:vr = COPY %2:vr
%4:vr = PseudoVMV_S_X %4:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype

-> post-ra pesudo expand

dead $x0 = PseudoVSETVLIX0 killed $x0, 136, implicit-def $vl, implicit-def $vtype, implicit $vl
$v10 = PseudoVMV_V_I_M1 undef $v10(tied-def 0), 0, 8, 4, 0, implicit $vl, implicit $vtype
renamable $v10 = PseudoVMV_S_X killed renamable $v10(tied-def 0), killed renamable $x11, 8, 4, implicit $vl, implicit $vtype
```

vsetvl insert after twoaddr

```
%4:vr = PseudoVMV_S_X %2:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype

-> two-addr

%4:vr = COPY %2:vr
%4:vr = PseudoVMV_S_X %4:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype

->vsetvl insertion 

%4:vr = COPY %2:vr
dead $x0 = PseudoVSETVLIX0 killed $x0, 136, implicit-def $vl, implicit-def $vtype, implicit $vl
%4:vr = PseudoVMV_S_X %4:vr(tied-def 0), killed %3:gpr, 8, 4, implicit $vl, implicit $vtype

-> post-ra pesudo expand

$v10 = PseudoVMV_V_I_M1 undef $v10(tied-def 0), 0, 8, 4, 0, implicit $vl, implicit $vtype
dead $x0 = PseudoVSETVLIX0 killed $x0, 136, implicit-def $vl, implicit-def $vtype, implicit $vl
renamable $v10 = PseudoVMV_S_X killed renamable $v10(tied-def 0), killed renamable $x11, 8, 4, implicit $vl, implicit $vtype
```



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


More information about the llvm-commits mailing list