1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -mvscale-min=1 -mvscale-max=1 -O1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-64
3 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -mvscale-min=4 -mvscale-max=4 -O1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-256
5 // REQUIRES: riscv-registered-target
9 typedef __rvv_int8m1_t vint8m1_t
;
10 typedef __rvv_uint8m1_t vuint8m1_t
;
11 typedef __rvv_int16m1_t vint16m1_t
;
12 typedef __rvv_uint16m1_t vuint16m1_t
;
13 typedef __rvv_int32m1_t vint32m1_t
;
14 typedef __rvv_uint32m1_t vuint32m1_t
;
15 typedef __rvv_int64m1_t vint64m1_t
;
16 typedef __rvv_uint64m1_t vuint64m1_t
;
17 typedef __rvv_float32m1_t vfloat32m1_t
;
18 typedef __rvv_float64m1_t vfloat64m1_t
;
20 typedef __rvv_bool1_t vbool1_t
;
21 typedef __rvv_bool4_t vbool4_t
;
22 typedef __rvv_bool32_t vbool32_t
;
24 typedef vint64m1_t fixed_int64m1_t
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen
)));
25 typedef vbool1_t fixed_bool1_t
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen
)));
26 typedef vbool4_t fixed_bool4_t
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen
/4)));
27 #if __riscv_v_fixed_vlen >= 256
28 typedef vbool32_t fixed_bool32_t
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen
/32)));
31 fixed_int64m1_t global_i64
;
33 fixed_bool1_t global_bool1
;
34 fixed_bool4_t global_bool4
;
35 #if __riscv_v_fixed_vlen >= 256
36 fixed_bool32_t global_bool32
;
39 //===----------------------------------------------------------------------===//
41 //===----------------------------------------------------------------------===//
43 // CHECK-64-LABEL: @write_global_i64(
44 // CHECK-64-NEXT: entry:
45 // CHECK-64-NEXT: [[CAST_FIXED:%.*]] = tail call <1 x i64> @llvm.vector.extract.v1i64.nxv1i64(<vscale x 1 x i64> [[V:%.*]], i64 0)
46 // CHECK-64-NEXT: store <1 x i64> [[CAST_FIXED]], ptr @global_i64, align 8, !tbaa [[TBAA6:![0-9]+]]
47 // CHECK-64-NEXT: ret void
49 // CHECK-256-LABEL: @write_global_i64(
50 // CHECK-256-NEXT: entry:
51 // CHECK-256-NEXT: [[CAST_FIXED:%.*]] = tail call <4 x i64> @llvm.vector.extract.v4i64.nxv1i64(<vscale x 1 x i64> [[V:%.*]], i64 0)
52 // CHECK-256-NEXT: store <4 x i64> [[CAST_FIXED]], ptr @global_i64, align 8, !tbaa [[TBAA6:![0-9]+]]
53 // CHECK-256-NEXT: ret void
55 void write_global_i64(vint64m1_t v
) { global_i64
= v
; }
57 // CHECK-64-LABEL: @write_global_bool1(
58 // CHECK-64-NEXT: entry:
59 // CHECK-64-NEXT: [[TMP0:%.*]] = bitcast <vscale x 64 x i1> [[V:%.*]] to <vscale x 8 x i8>
60 // CHECK-64-NEXT: [[CAST_FIXED:%.*]] = tail call <8 x i8> @llvm.vector.extract.v8i8.nxv8i8(<vscale x 8 x i8> [[TMP0]], i64 0)
61 // CHECK-64-NEXT: store <8 x i8> [[CAST_FIXED]], ptr @global_bool1, align 8, !tbaa [[TBAA6]]
62 // CHECK-64-NEXT: ret void
64 // CHECK-256-LABEL: @write_global_bool1(
65 // CHECK-256-NEXT: entry:
66 // CHECK-256-NEXT: [[TMP0:%.*]] = bitcast <vscale x 64 x i1> [[V:%.*]] to <vscale x 8 x i8>
67 // CHECK-256-NEXT: [[CAST_FIXED:%.*]] = tail call <32 x i8> @llvm.vector.extract.v32i8.nxv8i8(<vscale x 8 x i8> [[TMP0]], i64 0)
68 // CHECK-256-NEXT: store <32 x i8> [[CAST_FIXED]], ptr @global_bool1, align 8, !tbaa [[TBAA6]]
69 // CHECK-256-NEXT: ret void
71 void write_global_bool1(vbool1_t v
) { global_bool1
= v
; }
73 // CHECK-64-LABEL: @write_global_bool4(
74 // CHECK-64-NEXT: entry:
75 // CHECK-64-NEXT: [[TMP0:%.*]] = bitcast <vscale x 16 x i1> [[V:%.*]] to <vscale x 2 x i8>
76 // CHECK-64-NEXT: [[CAST_FIXED:%.*]] = tail call <2 x i8> @llvm.vector.extract.v2i8.nxv2i8(<vscale x 2 x i8> [[TMP0]], i64 0)
77 // CHECK-64-NEXT: store <2 x i8> [[CAST_FIXED]], ptr @global_bool4, align 2, !tbaa [[TBAA6]]
78 // CHECK-64-NEXT: ret void
80 // CHECK-256-LABEL: @write_global_bool4(
81 // CHECK-256-NEXT: entry:
82 // CHECK-256-NEXT: [[TMP0:%.*]] = bitcast <vscale x 16 x i1> [[V:%.*]] to <vscale x 2 x i8>
83 // CHECK-256-NEXT: [[CAST_FIXED:%.*]] = tail call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> [[TMP0]], i64 0)
84 // CHECK-256-NEXT: store <8 x i8> [[CAST_FIXED]], ptr @global_bool4, align 8, !tbaa [[TBAA6]]
85 // CHECK-256-NEXT: ret void
87 void write_global_bool4(vbool4_t v
) { global_bool4
= v
; }
89 #if __riscv_v_fixed_vlen >= 256
90 // CHECK-256-LABEL: @write_global_bool32(
91 // CHECK-256-NEXT: entry:
92 // CHECK-256-NEXT: [[SAVED_VALUE:%.*]] = alloca <vscale x 2 x i1>, align 1
93 // CHECK-256-NEXT: store <vscale x 2 x i1> [[V:%.*]], ptr [[SAVED_VALUE]], align 1, !tbaa [[TBAA9:![0-9]+]]
94 // CHECK-256-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[SAVED_VALUE]], align 1, !tbaa [[TBAA6]]
95 // CHECK-256-NEXT: store <1 x i8> [[TMP0]], ptr @global_bool32, align 1, !tbaa [[TBAA6]]
96 // CHECK-256-NEXT: ret void
98 void write_global_bool32(vbool32_t v
) { global_bool32
= v
; }
101 //===----------------------------------------------------------------------===//
103 //===----------------------------------------------------------------------===//
105 // CHECK-64-LABEL: @read_global_i64(
106 // CHECK-64-NEXT: entry:
107 // CHECK-64-NEXT: [[TMP0:%.*]] = load <1 x i64>, ptr @global_i64, align 8, !tbaa [[TBAA6]]
108 // CHECK-64-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 1 x i64> @llvm.vector.insert.nxv1i64.v1i64(<vscale x 1 x i64> poison, <1 x i64> [[TMP0]], i64 0)
109 // CHECK-64-NEXT: ret <vscale x 1 x i64> [[CAST_SCALABLE]]
111 // CHECK-256-LABEL: @read_global_i64(
112 // CHECK-256-NEXT: entry:
113 // CHECK-256-NEXT: [[TMP0:%.*]] = load <4 x i64>, ptr @global_i64, align 8, !tbaa [[TBAA6]]
114 // CHECK-256-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 1 x i64> @llvm.vector.insert.nxv1i64.v4i64(<vscale x 1 x i64> poison, <4 x i64> [[TMP0]], i64 0)
115 // CHECK-256-NEXT: ret <vscale x 1 x i64> [[CAST_SCALABLE]]
117 vint64m1_t
read_global_i64() { return global_i64
; }
119 // CHECK-64-LABEL: @read_global_bool1(
120 // CHECK-64-NEXT: entry:
121 // CHECK-64-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr @global_bool1, align 8, !tbaa [[TBAA6]]
122 // CHECK-64-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 8 x i8> @llvm.vector.insert.nxv8i8.v8i8(<vscale x 8 x i8> poison, <8 x i8> [[TMP0]], i64 0)
123 // CHECK-64-NEXT: [[TMP1:%.*]] = bitcast <vscale x 8 x i8> [[CAST_SCALABLE]] to <vscale x 64 x i1>
124 // CHECK-64-NEXT: ret <vscale x 64 x i1> [[TMP1]]
126 // CHECK-256-LABEL: @read_global_bool1(
127 // CHECK-256-NEXT: entry:
128 // CHECK-256-NEXT: [[TMP0:%.*]] = load <32 x i8>, ptr @global_bool1, align 8, !tbaa [[TBAA6]]
129 // CHECK-256-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 8 x i8> @llvm.vector.insert.nxv8i8.v32i8(<vscale x 8 x i8> poison, <32 x i8> [[TMP0]], i64 0)
130 // CHECK-256-NEXT: [[TMP1:%.*]] = bitcast <vscale x 8 x i8> [[CAST_SCALABLE]] to <vscale x 64 x i1>
131 // CHECK-256-NEXT: ret <vscale x 64 x i1> [[TMP1]]
133 vbool1_t
read_global_bool1() { return global_bool1
; }
135 // CHECK-64-LABEL: @read_global_bool4(
136 // CHECK-64-NEXT: entry:
137 // CHECK-64-NEXT: [[TMP0:%.*]] = load <2 x i8>, ptr @global_bool4, align 2, !tbaa [[TBAA6]]
138 // CHECK-64-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v2i8(<vscale x 2 x i8> poison, <2 x i8> [[TMP0]], i64 0)
139 // CHECK-64-NEXT: [[TMP1:%.*]] = bitcast <vscale x 2 x i8> [[CAST_SCALABLE]] to <vscale x 16 x i1>
140 // CHECK-64-NEXT: ret <vscale x 16 x i1> [[TMP1]]
142 // CHECK-256-LABEL: @read_global_bool4(
143 // CHECK-256-NEXT: entry:
144 // CHECK-256-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr @global_bool4, align 8, !tbaa [[TBAA6]]
145 // CHECK-256-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v8i8(<vscale x 2 x i8> poison, <8 x i8> [[TMP0]], i64 0)
146 // CHECK-256-NEXT: [[TMP1:%.*]] = bitcast <vscale x 2 x i8> [[CAST_SCALABLE]] to <vscale x 16 x i1>
147 // CHECK-256-NEXT: ret <vscale x 16 x i1> [[TMP1]]
149 vbool4_t
read_global_bool4() { return global_bool4
; }
151 #if __riscv_v_fixed_vlen >= 256
152 // CHECK-256-LABEL: @read_global_bool32(
153 // CHECK-256-NEXT: entry:
154 // CHECK-256-NEXT: [[SAVED_VALUE:%.*]] = alloca <1 x i8>, align 1
155 // CHECK-256-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr @global_bool32, align 1, !tbaa [[TBAA6]]
156 // CHECK-256-NEXT: store <1 x i8> [[TMP0]], ptr [[SAVED_VALUE]], align 1, !tbaa [[TBAA6]]
157 // CHECK-256-NEXT: [[TMP1:%.*]] = load <vscale x 2 x i1>, ptr [[SAVED_VALUE]], align 1, !tbaa [[TBAA6]]
158 // CHECK-256-NEXT: ret <vscale x 2 x i1> [[TMP1]]
160 vbool32_t
read_global_bool32() { return global_bool32
; }