xref: /llvm-project/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-splat-bf16.ll (revision ff0f2011e475141454028bce9cf7c6ff37a49620)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv32 -target-abi=ilp32d -mattr=+v,+zfbfmin,+zvfbfmin -verify-machineinstrs < %s | FileCheck %s --check-prefixes=ZFBFMIN-ZVFBFMIN
3; RUN: llc -mtriple=riscv32 -target-abi=ilp32d -mattr=+v,+zvfbfmin -verify-machineinstrs < %s | FileCheck %s --check-prefixes=ZVFBFMIN
4; RUN: llc -mtriple=riscv64 -target-abi=lp64d -mattr=+v,+zfbfmin,+zvfbfmin -verify-machineinstrs < %s | FileCheck %s --check-prefixes=ZFBFMIN-ZVFBFMIN
5; RUN: llc -mtriple=riscv64 -target-abi=lp64d -mattr=+v,+zvfbfmin -verify-machineinstrs < %s | FileCheck %s --check-prefixes=ZVFBFMIN
6
7define <8 x bfloat> @splat_v8bf16(ptr %x, bfloat %y) {
8; ZFBFMIN-ZVFBFMIN-LABEL: splat_v8bf16:
9; ZFBFMIN-ZVFBFMIN:       # %bb.0:
10; ZFBFMIN-ZVFBFMIN-NEXT:    fmv.x.h a0, fa0
11; ZFBFMIN-ZVFBFMIN-NEXT:    vsetivli zero, 8, e16, m1, ta, ma
12; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.x v8, a0
13; ZFBFMIN-ZVFBFMIN-NEXT:    ret
14;
15; ZVFBFMIN-LABEL: splat_v8bf16:
16; ZVFBFMIN:       # %bb.0:
17; ZVFBFMIN-NEXT:    fmv.x.w a0, fa0
18; ZVFBFMIN-NEXT:    vsetivli zero, 8, e16, m1, ta, ma
19; ZVFBFMIN-NEXT:    vmv.v.x v8, a0
20; ZVFBFMIN-NEXT:    ret
21  %a = insertelement <8 x bfloat> poison, bfloat %y, i32 0
22  %b = shufflevector <8 x bfloat> %a, <8 x bfloat> poison, <8 x i32> zeroinitializer
23  ret <8 x bfloat> %b
24}
25
26define <16 x bfloat> @splat_16bf16(ptr %x, bfloat %y) {
27; ZFBFMIN-ZVFBFMIN-LABEL: splat_16bf16:
28; ZFBFMIN-ZVFBFMIN:       # %bb.0:
29; ZFBFMIN-ZVFBFMIN-NEXT:    fmv.x.h a0, fa0
30; ZFBFMIN-ZVFBFMIN-NEXT:    vsetivli zero, 16, e16, m2, ta, ma
31; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.x v8, a0
32; ZFBFMIN-ZVFBFMIN-NEXT:    ret
33;
34; ZVFBFMIN-LABEL: splat_16bf16:
35; ZVFBFMIN:       # %bb.0:
36; ZVFBFMIN-NEXT:    fmv.x.w a0, fa0
37; ZVFBFMIN-NEXT:    vsetivli zero, 16, e16, m2, ta, ma
38; ZVFBFMIN-NEXT:    vmv.v.x v8, a0
39; ZVFBFMIN-NEXT:    ret
40  %a = insertelement <16 x bfloat> poison, bfloat %y, i32 0
41  %b = shufflevector <16 x bfloat> %a, <16 x bfloat> poison, <16 x i32> zeroinitializer
42  ret <16 x bfloat> %b
43}
44
45define <64 x bfloat> @splat_64bf16(ptr %x, bfloat %y) {
46; ZFBFMIN-ZVFBFMIN-LABEL: splat_64bf16:
47; ZFBFMIN-ZVFBFMIN:       # %bb.0:
48; ZFBFMIN-ZVFBFMIN-NEXT:    fmv.x.h a0, fa0
49; ZFBFMIN-ZVFBFMIN-NEXT:    li a1, 64
50; ZFBFMIN-ZVFBFMIN-NEXT:    vsetvli zero, a1, e16, m8, ta, ma
51; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.x v8, a0
52; ZFBFMIN-ZVFBFMIN-NEXT:    ret
53;
54; ZVFBFMIN-LABEL: splat_64bf16:
55; ZVFBFMIN:       # %bb.0:
56; ZVFBFMIN-NEXT:    fmv.x.w a0, fa0
57; ZVFBFMIN-NEXT:    li a1, 64
58; ZVFBFMIN-NEXT:    vsetvli zero, a1, e16, m8, ta, ma
59; ZVFBFMIN-NEXT:    vmv.v.x v8, a0
60; ZVFBFMIN-NEXT:    ret
61  %a = insertelement <64 x bfloat> poison, bfloat %y, i32 0
62  %b = shufflevector <64 x bfloat> %a, <64 x bfloat> poison, <64 x i32> zeroinitializer
63  ret <64 x bfloat> %b
64}
65
66define <8 x bfloat> @splat_zero_v8bf16(ptr %x) {
67; ZFBFMIN-ZVFBFMIN-LABEL: splat_zero_v8bf16:
68; ZFBFMIN-ZVFBFMIN:       # %bb.0:
69; ZFBFMIN-ZVFBFMIN-NEXT:    vsetivli zero, 8, e16, m1, ta, ma
70; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.i v8, 0
71; ZFBFMIN-ZVFBFMIN-NEXT:    ret
72;
73; ZVFBFMIN-LABEL: splat_zero_v8bf16:
74; ZVFBFMIN:       # %bb.0:
75; ZVFBFMIN-NEXT:    vsetivli zero, 8, e16, m1, ta, ma
76; ZVFBFMIN-NEXT:    vmv.v.i v8, 0
77; ZVFBFMIN-NEXT:    ret
78  ret <8 x bfloat> splat (bfloat 0.0)
79}
80
81define <16 x bfloat> @splat_zero_16bf16(ptr %x) {
82; ZFBFMIN-ZVFBFMIN-LABEL: splat_zero_16bf16:
83; ZFBFMIN-ZVFBFMIN:       # %bb.0:
84; ZFBFMIN-ZVFBFMIN-NEXT:    vsetivli zero, 16, e16, m2, ta, ma
85; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.i v8, 0
86; ZFBFMIN-ZVFBFMIN-NEXT:    ret
87;
88; ZVFBFMIN-LABEL: splat_zero_16bf16:
89; ZVFBFMIN:       # %bb.0:
90; ZVFBFMIN-NEXT:    vsetivli zero, 16, e16, m2, ta, ma
91; ZVFBFMIN-NEXT:    vmv.v.i v8, 0
92; ZVFBFMIN-NEXT:    ret
93  ret <16 x bfloat> splat (bfloat 0.0)
94}
95
96define <8 x bfloat> @splat_negzero_v8bf16(ptr %x) {
97; ZFBFMIN-ZVFBFMIN-LABEL: splat_negzero_v8bf16:
98; ZFBFMIN-ZVFBFMIN:       # %bb.0:
99; ZFBFMIN-ZVFBFMIN-NEXT:    lui a0, 1048568
100; ZFBFMIN-ZVFBFMIN-NEXT:    vsetivli zero, 8, e16, m1, ta, ma
101; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.x v8, a0
102; ZFBFMIN-ZVFBFMIN-NEXT:    ret
103;
104; ZVFBFMIN-LABEL: splat_negzero_v8bf16:
105; ZVFBFMIN:       # %bb.0:
106; ZVFBFMIN-NEXT:    lui a0, 1048568
107; ZVFBFMIN-NEXT:    vsetivli zero, 8, e16, m1, ta, ma
108; ZVFBFMIN-NEXT:    vmv.v.x v8, a0
109; ZVFBFMIN-NEXT:    ret
110  ret <8 x bfloat> splat (bfloat -0.0)
111}
112
113define <16 x bfloat> @splat_negzero_16bf16(ptr %x) {
114; ZFBFMIN-ZVFBFMIN-LABEL: splat_negzero_16bf16:
115; ZFBFMIN-ZVFBFMIN:       # %bb.0:
116; ZFBFMIN-ZVFBFMIN-NEXT:    lui a0, 1048568
117; ZFBFMIN-ZVFBFMIN-NEXT:    vsetivli zero, 16, e16, m2, ta, ma
118; ZFBFMIN-ZVFBFMIN-NEXT:    vmv.v.x v8, a0
119; ZFBFMIN-ZVFBFMIN-NEXT:    ret
120;
121; ZVFBFMIN-LABEL: splat_negzero_16bf16:
122; ZVFBFMIN:       # %bb.0:
123; ZVFBFMIN-NEXT:    lui a0, 1048568
124; ZVFBFMIN-NEXT:    vsetivli zero, 16, e16, m2, ta, ma
125; ZVFBFMIN-NEXT:    vmv.v.x v8, a0
126; ZVFBFMIN-NEXT:    ret
127  ret <16 x bfloat> splat (bfloat -0.0)
128}
129