Skip to content

Commit a1c0e4a

Browse files
committed
[RISCV] Add implicit operand {VL, VTYPE} in RISCVInsertVSETVLI when using inline assembly.
1 parent f120b0d commit a1c0e4a

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,13 @@ void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &MBB) {
15311531
/*isImp*/ true));
15321532
}
15331533

1534+
if (MI.isInlineAsm()) {
1535+
MI.addOperand(MachineOperand::CreateReg(RISCV::VL, /*isDef*/ true,
1536+
/*isImp*/ true));
1537+
MI.addOperand(MachineOperand::CreateReg(RISCV::VTYPE, /*isDef*/ true,
1538+
/*isImp*/ true));
1539+
}
1540+
15341541
if (MI.isCall() || MI.isInlineAsm() ||
15351542
MI.modifiesRegister(RISCV::VL, /*TRI=*/nullptr) ||
15361543
MI.modifiesRegister(RISCV::VTYPE, /*TRI=*/nullptr))
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=riscv64 -mcpu=sifive-x280 -verify-machineinstrs < %s | FileCheck %s
3+
4+
define void @foo(<vscale x 8 x half> %0, <vscale x 8 x half> %1) {
5+
; CHECK-LABEL: foo:
6+
; CHECK: # %bb.0: # %entry
7+
; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
8+
; CHECK-NEXT: vmv.v.i v12, 0
9+
; CHECK-NEXT: lui a0, 1
10+
; CHECK-NEXT: addiw a0, a0, -1096
11+
; CHECK-NEXT: vmv.v.i v16, 0
12+
; CHECK-NEXT: vsetvli zero, a0, e8, m1, ta, ma
13+
; CHECK-NEXT: #APP
14+
; CHECK-NEXT: vfmadd.vv v16, v12, v12
15+
; CHECK-NEXT: #NO_APP
16+
; CHECK-NEXT: #APP
17+
; CHECK-NEXT: vfmadd.vv v16, v12, v12
18+
; CHECK-NEXT: #NO_APP
19+
; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma
20+
; CHECK-NEXT: vse16.v v8, (zero)
21+
; CHECK-NEXT: ret
22+
entry:
23+
%2 = tail call i64 @llvm.riscv.vsetvli.i64(i64 3000, i64 0, i64 0)
24+
%3 = tail call <vscale x 8 x float> asm sideeffect "vfmadd.vv $0, $1, $2", "=^vr,^vr,^vr,0"(<vscale x 8 x float> zeroinitializer, <vscale x 8 x float> zeroinitializer, <vscale x 8 x float> zeroinitializer)
25+
%4 = tail call <vscale x 8 x float> asm sideeffect "vfmadd.vv $0, $1, $2", "=^vr,^vr,^vr,0"(<vscale x 8 x float> zeroinitializer, <vscale x 8 x float> zeroinitializer, <vscale x 8 x float> %3)
26+
tail call void @llvm.riscv.vse.nxv8f16.i64(<vscale x 8 x half> %0, ptr null, i64 %2)
27+
ret void
28+
}
29+
30+
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
31+
declare i64 @llvm.riscv.vsetvli.i64(i64, i64 immarg, i64 immarg) #0
32+
33+
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: write)
34+
declare void @llvm.riscv.vse.nxv8f16.i64(<vscale x 8 x half>, ptr nocapture, i64) #1
35+
36+
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
37+
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: write) }

0 commit comments

Comments
 (0)