Skip to content

Commit 2ed2975

Browse files
committed
[RISCV] Add isel patterns for bf16 riscv_vfmv_v_f_vl of FP constant.
We try not let bf16 splats through to isel, but constant folding allows FP constants to get through. Thankfully we can handle those using vmv.v.i or vmv.v.x.
1 parent f3aceee commit 2ed2975

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ foreach fvti = AllFloatVectors in {
26542654
}
26552655
}
26562656

2657-
foreach fvti = AllFloatVectors in {
2657+
foreach fvti = !listconcat(AllFloatVectors, AllBFloatVectors) in {
26582658
defvar ivti = GetIntVTypeInfo<fvti>.Vti;
26592659
let Predicates = GetVTypePredicates<ivti>.Predicates in {
26602660
// 13.16. Vector Floating-Point Move Instruction
@@ -2668,7 +2668,9 @@ foreach fvti = AllFloatVectors in {
26682668
(!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX)
26692669
$passthru, GPR:$imm, GPR:$vl, fvti.Log2SEW, TU_MU)>;
26702670
}
2671+
}
26712672

2673+
foreach fvti = AllFloatVectors in {
26722674
let Predicates = GetVTypePredicates<fvti>.Predicates in {
26732675
def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
26742676
fvti.Vector:$passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)),
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=riscv32 -mattr=+f,+d,+experimental-zfbfmin,+experimental-zvfbfmin,+v -target-abi ilp32d -verify-machineinstrs < %s \
3+
; RUN: | FileCheck %s
4+
; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+experimental-zfbfmin,+experimental-zvfbfmin,+v -target-abi lp64d -verify-machineinstrs < %s \
5+
; RUN: | FileCheck %s
6+
7+
define <vscale x 8 x bfloat> @vsplat_zero_nxv8f16() {
8+
; CHECK-LABEL: vsplat_zero_nxv8f16:
9+
; CHECK: # %bb.0:
10+
; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
11+
; CHECK-NEXT: vmv.v.i v8, 0
12+
; CHECK-NEXT: ret
13+
ret <vscale x 8 x bfloat> splat (bfloat zeroinitializer)
14+
}
15+
16+
define <vscale x 8 x bfloat> @vsplat_negzero_nxv8f16() {
17+
; CHECK-LABEL: vsplat_negzero_nxv8f16:
18+
; CHECK: # %bb.0:
19+
; CHECK-NEXT: lui a0, 1048568
20+
; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
21+
; CHECK-NEXT: vmv.v.x v8, a0
22+
; CHECK-NEXT: ret
23+
ret <vscale x 8 x bfloat> splat (bfloat -0.0)
24+
}

0 commit comments

Comments
 (0)