Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/AArch64/acle_sve_dup.c

raw
1 // REQUIRES: aarch64-registered-target
2
3 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-cir -o - %s | FileCheck %s --check-prefixes=ALL,CIR
4 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-cir -o - %s | FileCheck %s --check-prefixes=ALL,CIR
5
6 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
7 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
8
9 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
10 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR
11 #include <arm_sve.h>
12
13 #if defined __ARM_FEATURE_SME
14 #define MODE_ATTR __arm_streaming
15 #else
16 #define MODE_ATTR
17 #endif
18
19 #ifdef SVE_OVERLOADED_FORMS
20 // A simple used,unused... macro, long enough to represent any SVE builtin.
21 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
22 #else
23 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
24 #endif
25
26 // ALL-LABEL: @test_svdup_n_s8
27 svint8_t test_svdup_n_s8(int8_t op) MODE_ATTR
28 {
29 // CIR-SAME: %[[OP:.*]]: !s8i {{.*}} -> !cir.vector<[16] x !s8i>
30 // CIR: %[[ALLOCA:.*]] = cir.alloca
31 // CIR: cir.store %[[OP]], %[[ALLOCA]]
32 // CIR: %[[LOAD:.*]] = cir.load align(1) %[[ALLOCA]]
33 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!s8i) -> !cir.vector<[16] x !s8i>
34
35 // LLVM_OGCG_CIR-SAME: i8 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
36 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i8,{{([[:space:]]?i64 1,)?}} align 1
37 // LLVM_OGCG_CIR: store i8 [[OP]], ptr [[OP_ADDR]], align 1
38 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i8, ptr [[OP_ADDR]], align 1
39 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.dup.x.nxv16i8(i8 [[OP_LOAD]])
40 return SVE_ACLE_FUNC(svdup,_n,_s8,)(op);
41 }
42
43 // ALL-LABEL: @test_svdup_n_s16
44 svint16_t test_svdup_n_s16(int16_t op) MODE_ATTR
45 {
46 // CIR-SAME: %[[OP:.*]]: !s16i {{.*}} -> !cir.vector<[8] x !s16i>
47 // CIR: %[[ALLOCA:.*]] = cir.alloca
48 // CIR: cir.store %[[OP]], %[[ALLOCA]]
49 // CIR: %[[LOAD:.*]] = cir.load align(2) %[[ALLOCA]]
50 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!s16i) -> !cir.vector<[8] x !s16i>
51
52 // LLVM_OGCG_CIR-SAME: i16 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
53 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i16,{{([[:space:]]?i64 1,)?}} align 2
54 // LLVM_OGCG_CIR: store i16 [[OP]], ptr [[OP_ADDR]], align 2
55 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i16, ptr [[OP_ADDR]], align 2
56 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.dup.x.nxv8i16(i16 [[OP_LOAD]])
57 return SVE_ACLE_FUNC(svdup,_n,_s16,)(op);
58 }
59
60 // ALL-LABEL: @test_svdup_n_s32
61 svint32_t test_svdup_n_s32(int32_t op) MODE_ATTR
62 {
63 // CIR-SAME: %[[OP:.*]]: !s32i {{.*}} -> !cir.vector<[4] x !s32i>
64 // CIR: %[[ALLOCA:.*]] = cir.alloca
65 // CIR: cir.store %[[OP]], %[[ALLOCA]]
66 // CIR: %[[LOAD:.*]] = cir.load align(4) %[[ALLOCA]]
67 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!s32i) -> !cir.vector<[4] x !s32i>
68
69 // LLVM_OGCG_CIR-SAME: i32 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
70 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i32,{{([[:space:]]?i64 1,)?}} align 4
71 // LLVM_OGCG_CIR: store i32 [[OP]], ptr [[OP_ADDR]], align 4
72 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i32, ptr [[OP_ADDR]], align 4
73 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.dup.x.nxv4i32(i32 [[OP_LOAD]])
74 return SVE_ACLE_FUNC(svdup,_n,_s32,)(op);
75 }
76
77 // ALL-LABEL: @test_svdup_n_s64
78 svint64_t test_svdup_n_s64(int64_t op) MODE_ATTR
79 {
80 // CIR-SAME: %[[OP:.*]]: !s64i {{.*}} -> !cir.vector<[2] x !s64i>
81 // CIR: %[[ALLOCA:.*]] = cir.alloca
82 // CIR: cir.store %[[OP]], %[[ALLOCA]]
83 // CIR: %[[LOAD:.*]] = cir.load align(8) %[[ALLOCA]]
84 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!s64i) -> !cir.vector<[2] x !s64i>
85
86 // LLVM_OGCG_CIR-SAME: i64 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
87 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i64,{{([[:space:]]?i64 1,)?}} align 8
88 // LLVM_OGCG_CIR: store i64 [[OP]], ptr [[OP_ADDR]], align 8
89 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i64, ptr [[OP_ADDR]], align 8
90 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 [[OP_LOAD]])
91 return SVE_ACLE_FUNC(svdup,_n,_s64,)(op);
92 }
93
94 // ALL-LABEL: @test_svdup_n_u8
95 svuint8_t test_svdup_n_u8(uint8_t op) MODE_ATTR
96 {
97 // CIR-SAME: %[[OP:.*]]: !u8i {{.*}} -> !cir.vector<[16] x !u8i>
98 // CIR: %[[ALLOCA:.*]] = cir.alloca
99 // CIR: cir.store %[[OP]], %[[ALLOCA]]
100 // CIR: %[[LOAD:.*]] = cir.load align(1) %[[ALLOCA]]
101 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!u8i) -> !cir.vector<[16] x !u8i>
102
103 // LLVM_OGCG_CIR-SAME: i8 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
104 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i8,{{([[:space:]]?i64 1,)?}} align 1
105 // LLVM_OGCG_CIR: store i8 [[OP]], ptr [[OP_ADDR]], align 1
106 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i8, ptr [[OP_ADDR]], align 1
107 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.dup.x.nxv16i8(i8 [[OP_LOAD]])
108 return SVE_ACLE_FUNC(svdup,_n,_u8,)(op);
109 }
110
111 // ALL-LABEL: @test_svdup_n_u16
112 svuint16_t test_svdup_n_u16(uint16_t op) MODE_ATTR
113 {
114 // CIR-SAME: %[[OP:.*]]: !u16i {{.*}} -> !cir.vector<[8] x !u16i>
115 // CIR: %[[ALLOCA:.*]] = cir.alloca
116 // CIR: cir.store %[[OP]], %[[ALLOCA]]
117 // CIR: %[[LOAD:.*]] = cir.load align(2) %[[ALLOCA]]
118 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!u16i) -> !cir.vector<[8] x !u16i>
119
120 // LLVM_OGCG_CIR-SAME: i16 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
121 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i16,{{([[:space:]]?i64 1,)?}} align 2
122 // LLVM_OGCG_CIR: store i16 [[OP]], ptr [[OP_ADDR]], align 2
123 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i16, ptr [[OP_ADDR]], align 2
124 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.dup.x.nxv8i16(i16 [[OP_LOAD]])
125 return SVE_ACLE_FUNC(svdup,_n,_u16,)(op);
126 }
127
128 // ALL-LABEL: @test_svdup_n_u32
129 svuint32_t test_svdup_n_u32(uint32_t op) MODE_ATTR
130 {
131 // CIR-SAME: %[[OP:.*]]: !u32i {{.*}} -> !cir.vector<[4] x !u32i>
132 // CIR: %[[ALLOCA:.*]] = cir.alloca
133 // CIR: cir.store %[[OP]], %[[ALLOCA]]
134 // CIR: %[[LOAD:.*]] = cir.load align(4) %[[ALLOCA]]
135 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!u32i) -> !cir.vector<[4] x !u32i>
136
137 // LLVM_OGCG_CIR-SAME: i32 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
138 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i32,{{([[:space:]]?i64 1,)?}} align 4
139 // LLVM_OGCG_CIR: store i32 [[OP]], ptr [[OP_ADDR]], align 4
140 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i32, ptr [[OP_ADDR]], align 4
141 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.dup.x.nxv4i32(i32 [[OP_LOAD]])
142 return SVE_ACLE_FUNC(svdup,_n,_u32,)(op);
143 }
144
145 // ALL-LABEL: @test_svdup_n_u64
146 svuint64_t test_svdup_n_u64(uint64_t op) MODE_ATTR
147 {
148 // CIR-SAME: %[[OP:.*]]: !u64i {{.*}} -> !cir.vector<[2] x !u64i>
149 // CIR: %[[ALLOCA:.*]] = cir.alloca
150 // CIR: cir.store %[[OP]], %[[ALLOCA]]
151 // CIR: %[[LOAD:.*]] = cir.load align(8) %[[ALLOCA]]
152 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!u64i) -> !cir.vector<[2] x !u64i>
153
154 // LLVM_OGCG_CIR-SAME: i64 {{(noundef)?[[:space:]]?}}[[OP:%.*]])
155 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca i64,{{([[:space:]]?i64 1,)?}} align 8
156 // LLVM_OGCG_CIR: store i64 [[OP]], ptr [[OP_ADDR]], align 8
157 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load i64, ptr [[OP_ADDR]], align 8
158 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 [[OP_LOAD]])
159 return SVE_ACLE_FUNC(svdup,_n,_u64,)(op);
160 }
161
162 // ALL-LABEL: @test_svdup_n_f16
163 svfloat16_t test_svdup_n_f16(float16_t op) MODE_ATTR
164 {
165 // CIR-SAME: %[[OP:.*]]: !cir.f16 {{.*}} -> !cir.vector<[8] x !cir.f16>
166 // CIR: %[[ALLOCA:.*]] = cir.alloca
167 // CIR: cir.store %[[OP]], %[[ALLOCA]]
168 // CIR: %[[LOAD:.*]] = cir.load align(2) %[[ALLOCA]]
169 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!cir.f16) -> !cir.vector<[8] x !cir.f16>
170
171 // LLVM_OGCG_CIR-SAME: half {{(noundef)?[[:space:]]?}}[[OP:%.*]])
172 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca half,{{([[:space:]]?i64 1,)?}} align 2
173 // LLVM_OGCG_CIR: store half [[OP]], ptr [[OP_ADDR]], align 2
174 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load half, ptr [[OP_ADDR]], align 2
175 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.dup.x.nxv8f16(half [[OP_LOAD]])
176 return SVE_ACLE_FUNC(svdup,_n,_f16,)(op);
177 }
178
179 // ALL-LABEL: @test_svdup_n_f32
180 svfloat32_t test_svdup_n_f32(float32_t op) MODE_ATTR
181 {
182 // CIR-SAME: %[[OP:.*]]: !cir.float {{.*}} -> !cir.vector<[4] x !cir.float>
183 // CIR: %[[ALLOCA:.*]] = cir.alloca
184 // CIR: cir.store %[[OP]], %[[ALLOCA]]
185 // CIR: %[[LOAD:.*]] = cir.load align(4) %[[ALLOCA]]
186 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!cir.float) -> !cir.vector<[4] x !cir.float>
187
188 // LLVM_OGCG_CIR-SAME: float {{(noundef)?[[:space:]]?}}[[OP:%.*]])
189 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca float,{{([[:space:]]?i64 1,)?}} align 4
190 // LLVM_OGCG_CIR: store float [[OP]], ptr [[OP_ADDR]], align 4
191 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load float, ptr [[OP_ADDR]], align 4
192 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.dup.x.nxv4f32(float [[OP_LOAD]])
193 return SVE_ACLE_FUNC(svdup,_n,_f32,)(op);
194 }
195
196 // ALL-LABEL: @test_svdup_n_f64
197 svfloat64_t test_svdup_n_f64(float64_t op) MODE_ATTR
198 {
199 // CIR-SAME: %[[OP:.*]]: !cir.double {{.*}} -> !cir.vector<[2] x !cir.double>
200 // CIR: %[[ALLOCA:.*]] = cir.alloca
201 // CIR: cir.store %[[OP]], %[[ALLOCA]]
202 // CIR: %[[LOAD:.*]] = cir.load align(8) %[[ALLOCA]]
203 // CIR: cir.call_llvm_intrinsic "aarch64.sve.dup.x" %[[LOAD]] : (!cir.double) -> !cir.vector<[2] x !cir.double>
204
205 // LLVM_OGCG_CIR-SAME: double {{(noundef)?[[:space:]]?}}[[OP:%.*]])
206 // LLVM_OGCG_CIR: [[OP_ADDR:%.*]] = alloca double,{{([[:space:]]?i64 1,)?}} align 8
207 // LLVM_OGCG_CIR: store double [[OP]], ptr [[OP_ADDR]], align 8
208 // LLVM_OGCG_CIR: [[OP_LOAD:%.*]] = load double, ptr [[OP_ADDR]], align 8
209 // LLVM_OGCG_CIR: [[RES:%.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.dup.x.nxv2f64(double [[OP_LOAD]])
210 return SVE_ACLE_FUNC(svdup,_n,_f64,)(op);
211 }