1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+f,+d,+zfh,+zvfh,+v -target-abi ilp32d -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,OPTIMIZED
4 ; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+zfh,+zvfh,+v -target-abi lp64d -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s --check-prefixes=CHECK,OPTIMIZED
6 ; RUN: llc -mtriple=riscv32 -mattr=+f,+d,+zfh,+zvfh,+v,+no-optimized-zero-stride-load -target-abi ilp32d -verify-machineinstrs < %s \
7 ; RUN: | FileCheck %s --check-prefixes=CHECK,NOT-OPTIMIZED
8 ; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+zfh,+zvfh,+v,+no-optimized-zero-stride-load -target-abi lp64d -verify-machineinstrs < %s \
9 ; RUN: | FileCheck %s --check-prefixes=CHECK,NOT-OPTIMIZED
11 define <vscale x 8 x half> @vsplat_nxv8f16(half %f) {
12 ; CHECK-LABEL: vsplat_nxv8f16:
14 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
15 ; CHECK-NEXT: vfmv.v.f v8, fa0
17 %head = insertelement <vscale x 8 x half> poison, half %f, i32 0
18 %splat = shufflevector <vscale x 8 x half> %head, <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
19 ret <vscale x 8 x half> %splat
22 define <vscale x 8 x half> @vsplat_zero_nxv8f16() {
23 ; CHECK-LABEL: vsplat_zero_nxv8f16:
25 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
26 ; CHECK-NEXT: vmv.v.i v8, 0
28 %head = insertelement <vscale x 8 x half> poison, half zeroinitializer, i32 0
29 %splat = shufflevector <vscale x 8 x half> %head, <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
30 ret <vscale x 8 x half> %splat
33 define <vscale x 8 x float> @vsplat_nxv8f32(float %f) {
34 ; CHECK-LABEL: vsplat_nxv8f32:
36 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
37 ; CHECK-NEXT: vfmv.v.f v8, fa0
39 %head = insertelement <vscale x 8 x float> poison, float %f, i32 0
40 %splat = shufflevector <vscale x 8 x float> %head, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
41 ret <vscale x 8 x float> %splat
44 define <vscale x 8 x float> @vsplat_zero_nxv8f32() {
45 ; CHECK-LABEL: vsplat_zero_nxv8f32:
47 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
48 ; CHECK-NEXT: vmv.v.i v8, 0
50 %head = insertelement <vscale x 8 x float> poison, float zeroinitializer, i32 0
51 %splat = shufflevector <vscale x 8 x float> %head, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
52 ret <vscale x 8 x float> %splat
55 define <vscale x 8 x double> @vsplat_nxv8f64(double %f) {
56 ; CHECK-LABEL: vsplat_nxv8f64:
58 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
59 ; CHECK-NEXT: vfmv.v.f v8, fa0
61 %head = insertelement <vscale x 8 x double> poison, double %f, i32 0
62 %splat = shufflevector <vscale x 8 x double> %head, <vscale x 8 x double> poison, <vscale x 8 x i32> zeroinitializer
63 ret <vscale x 8 x double> %splat
66 define <vscale x 8 x double> @vsplat_zero_nxv8f64() {
67 ; CHECK-LABEL: vsplat_zero_nxv8f64:
69 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
70 ; CHECK-NEXT: vmv.v.i v8, 0
72 %head = insertelement <vscale x 8 x double> poison, double zeroinitializer, i32 0
73 %splat = shufflevector <vscale x 8 x double> %head, <vscale x 8 x double> poison, <vscale x 8 x i32> zeroinitializer
74 ret <vscale x 8 x double> %splat
77 ; Test that we fold this to a vlse with 0 stride.
78 define <vscale x 8 x float> @vsplat_load_nxv8f32(ptr %ptr) {
79 ; OPTIMIZED-LABEL: vsplat_load_nxv8f32:
81 ; OPTIMIZED-NEXT: vsetvli a1, zero, e32, m4, ta, ma
82 ; OPTIMIZED-NEXT: vlse32.v v8, (a0), zero
85 ; NOT-OPTIMIZED-LABEL: vsplat_load_nxv8f32:
86 ; NOT-OPTIMIZED: # %bb.0:
87 ; NOT-OPTIMIZED-NEXT: flw fa5, 0(a0)
88 ; NOT-OPTIMIZED-NEXT: vsetvli a0, zero, e32, m4, ta, ma
89 ; NOT-OPTIMIZED-NEXT: vfmv.v.f v8, fa5
90 ; NOT-OPTIMIZED-NEXT: ret
91 %f = load float, ptr %ptr
92 %head = insertelement <vscale x 8 x float> poison, float %f, i32 0
93 %splat = shufflevector <vscale x 8 x float> %head, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
94 ret <vscale x 8 x float> %splat