xref: /llvm-project/clang/test/CodeGen/AArch64/neon-scalar-copy.c (revision 207e5ccceec8d3cc3f32723e78f2a142bc61b07d)
1*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
2*207e5cccSFangrui Song // RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
3*207e5cccSFangrui Song 
4*207e5cccSFangrui Song // REQUIRES: aarch64-registered-target || arm-registered-target
5*207e5cccSFangrui Song 
6*207e5cccSFangrui Song #include <arm_neon.h>
7*207e5cccSFangrui Song 
8*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} float @test_vdups_lane_f32(<2 x float> noundef %a) #0 {
9*207e5cccSFangrui Song // CHECK:   [[VDUPS_LANE:%.*]] = extractelement <2 x float> %a, i32 1
10*207e5cccSFangrui Song // CHECK:   ret float [[VDUPS_LANE]]
11*207e5cccSFangrui Song float32_t test_vdups_lane_f32(float32x2_t a) {
12*207e5cccSFangrui Song   return vdups_lane_f32(a, 1);
13*207e5cccSFangrui Song }
14*207e5cccSFangrui Song 
15*207e5cccSFangrui Song 
16*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} double @test_vdupd_lane_f64(<1 x double> noundef %a) #0 {
17*207e5cccSFangrui Song // CHECK:   [[VDUPD_LANE:%.*]] = extractelement <1 x double> %a, i32 0
18*207e5cccSFangrui Song // CHECK:   ret double [[VDUPD_LANE]]
19*207e5cccSFangrui Song float64_t test_vdupd_lane_f64(float64x1_t a) {
20*207e5cccSFangrui Song   return vdupd_lane_f64(a, 0);
21*207e5cccSFangrui Song }
22*207e5cccSFangrui Song 
23*207e5cccSFangrui Song 
24*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} float @test_vdups_laneq_f32(<4 x float> noundef %a) #0 {
25*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <4 x float> %a, i32 3
26*207e5cccSFangrui Song // CHECK:   ret float [[VGETQ_LANE]]
27*207e5cccSFangrui Song float32_t test_vdups_laneq_f32(float32x4_t a) {
28*207e5cccSFangrui Song   return vdups_laneq_f32(a, 3);
29*207e5cccSFangrui Song }
30*207e5cccSFangrui Song 
31*207e5cccSFangrui Song 
32*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} double @test_vdupd_laneq_f64(<2 x double> noundef %a) #0 {
33*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <2 x double> %a, i32 1
34*207e5cccSFangrui Song // CHECK:   ret double [[VGETQ_LANE]]
35*207e5cccSFangrui Song float64_t test_vdupd_laneq_f64(float64x2_t a) {
36*207e5cccSFangrui Song   return vdupd_laneq_f64(a, 1);
37*207e5cccSFangrui Song }
38*207e5cccSFangrui Song 
39*207e5cccSFangrui Song 
40*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i8 @test_vdupb_lane_s8(<8 x i8> noundef %a) #0 {
41*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <8 x i8> %a, i32 7
42*207e5cccSFangrui Song // CHECK:   ret i8 [[VGET_LANE]]
43*207e5cccSFangrui Song int8_t test_vdupb_lane_s8(int8x8_t a) {
44*207e5cccSFangrui Song   return vdupb_lane_s8(a, 7);
45*207e5cccSFangrui Song }
46*207e5cccSFangrui Song 
47*207e5cccSFangrui Song 
48*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i16 @test_vduph_lane_s16(<4 x i16> noundef %a) #0 {
49*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <4 x i16> %a, i32 3
50*207e5cccSFangrui Song // CHECK:   ret i16 [[VGET_LANE]]
51*207e5cccSFangrui Song int16_t test_vduph_lane_s16(int16x4_t a) {
52*207e5cccSFangrui Song   return vduph_lane_s16(a, 3);
53*207e5cccSFangrui Song }
54*207e5cccSFangrui Song 
55*207e5cccSFangrui Song 
56*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i32 @test_vdups_lane_s32(<2 x i32> noundef %a) #0 {
57*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <2 x i32> %a, i32 1
58*207e5cccSFangrui Song // CHECK:   ret i32 [[VGET_LANE]]
59*207e5cccSFangrui Song int32_t test_vdups_lane_s32(int32x2_t a) {
60*207e5cccSFangrui Song   return vdups_lane_s32(a, 1);
61*207e5cccSFangrui Song }
62*207e5cccSFangrui Song 
63*207e5cccSFangrui Song 
64*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i64 @test_vdupd_lane_s64(<1 x i64> noundef %a) #0 {
65*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <1 x i64> %a, i32 0
66*207e5cccSFangrui Song // CHECK:   ret i64 [[VGET_LANE]]
67*207e5cccSFangrui Song int64_t test_vdupd_lane_s64(int64x1_t a) {
68*207e5cccSFangrui Song   return vdupd_lane_s64(a, 0);
69*207e5cccSFangrui Song }
70*207e5cccSFangrui Song 
71*207e5cccSFangrui Song 
72*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i8 @test_vdupb_lane_u8(<8 x i8> noundef %a) #0 {
73*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <8 x i8> %a, i32 7
74*207e5cccSFangrui Song // CHECK:   ret i8 [[VGET_LANE]]
75*207e5cccSFangrui Song uint8_t test_vdupb_lane_u8(uint8x8_t a) {
76*207e5cccSFangrui Song   return vdupb_lane_u8(a, 7);
77*207e5cccSFangrui Song }
78*207e5cccSFangrui Song 
79*207e5cccSFangrui Song 
80*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i16 @test_vduph_lane_u16(<4 x i16> noundef %a) #0 {
81*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <4 x i16> %a, i32 3
82*207e5cccSFangrui Song // CHECK:   ret i16 [[VGET_LANE]]
83*207e5cccSFangrui Song uint16_t test_vduph_lane_u16(uint16x4_t a) {
84*207e5cccSFangrui Song   return vduph_lane_u16(a, 3);
85*207e5cccSFangrui Song }
86*207e5cccSFangrui Song 
87*207e5cccSFangrui Song 
88*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i32 @test_vdups_lane_u32(<2 x i32> noundef %a) #0 {
89*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <2 x i32> %a, i32 1
90*207e5cccSFangrui Song // CHECK:   ret i32 [[VGET_LANE]]
91*207e5cccSFangrui Song uint32_t test_vdups_lane_u32(uint32x2_t a) {
92*207e5cccSFangrui Song   return vdups_lane_u32(a, 1);
93*207e5cccSFangrui Song }
94*207e5cccSFangrui Song 
95*207e5cccSFangrui Song 
96*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i64 @test_vdupd_lane_u64(<1 x i64> noundef %a) #0 {
97*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <1 x i64> %a, i32 0
98*207e5cccSFangrui Song // CHECK:   ret i64 [[VGET_LANE]]
99*207e5cccSFangrui Song uint64_t test_vdupd_lane_u64(uint64x1_t a) {
100*207e5cccSFangrui Song   return vdupd_lane_u64(a, 0);
101*207e5cccSFangrui Song }
102*207e5cccSFangrui Song 
103*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i8 @test_vdupb_laneq_s8(<16 x i8> noundef %a) #0 {
104*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <16 x i8> %a, i32 15
105*207e5cccSFangrui Song // CHECK:   ret i8 [[VGETQ_LANE]]
106*207e5cccSFangrui Song int8_t test_vdupb_laneq_s8(int8x16_t a) {
107*207e5cccSFangrui Song   return vdupb_laneq_s8(a, 15);
108*207e5cccSFangrui Song }
109*207e5cccSFangrui Song 
110*207e5cccSFangrui Song 
111*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i16 @test_vduph_laneq_s16(<8 x i16> noundef %a) #0 {
112*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <8 x i16> %a, i32 7
113*207e5cccSFangrui Song // CHECK:   ret i16 [[VGETQ_LANE]]
114*207e5cccSFangrui Song int16_t test_vduph_laneq_s16(int16x8_t a) {
115*207e5cccSFangrui Song   return vduph_laneq_s16(a, 7);
116*207e5cccSFangrui Song }
117*207e5cccSFangrui Song 
118*207e5cccSFangrui Song 
119*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i32 @test_vdups_laneq_s32(<4 x i32> noundef %a) #0 {
120*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <4 x i32> %a, i32 3
121*207e5cccSFangrui Song // CHECK:   ret i32 [[VGETQ_LANE]]
122*207e5cccSFangrui Song int32_t test_vdups_laneq_s32(int32x4_t a) {
123*207e5cccSFangrui Song   return vdups_laneq_s32(a, 3);
124*207e5cccSFangrui Song }
125*207e5cccSFangrui Song 
126*207e5cccSFangrui Song 
127*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i64 @test_vdupd_laneq_s64(<2 x i64> noundef %a) #0 {
128*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <2 x i64> %a, i32 1
129*207e5cccSFangrui Song // CHECK:   ret i64 [[VGETQ_LANE]]
130*207e5cccSFangrui Song int64_t test_vdupd_laneq_s64(int64x2_t a) {
131*207e5cccSFangrui Song   return vdupd_laneq_s64(a, 1);
132*207e5cccSFangrui Song }
133*207e5cccSFangrui Song 
134*207e5cccSFangrui Song 
135*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i8 @test_vdupb_laneq_u8(<16 x i8> noundef %a) #0 {
136*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <16 x i8> %a, i32 15
137*207e5cccSFangrui Song // CHECK:   ret i8 [[VGETQ_LANE]]
138*207e5cccSFangrui Song uint8_t test_vdupb_laneq_u8(uint8x16_t a) {
139*207e5cccSFangrui Song   return vdupb_laneq_u8(a, 15);
140*207e5cccSFangrui Song }
141*207e5cccSFangrui Song 
142*207e5cccSFangrui Song 
143*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i16 @test_vduph_laneq_u16(<8 x i16> noundef %a) #0 {
144*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <8 x i16> %a, i32 7
145*207e5cccSFangrui Song // CHECK:   ret i16 [[VGETQ_LANE]]
146*207e5cccSFangrui Song uint16_t test_vduph_laneq_u16(uint16x8_t a) {
147*207e5cccSFangrui Song   return vduph_laneq_u16(a, 7);
148*207e5cccSFangrui Song }
149*207e5cccSFangrui Song 
150*207e5cccSFangrui Song 
151*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i32 @test_vdups_laneq_u32(<4 x i32> noundef %a) #0 {
152*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <4 x i32> %a, i32 3
153*207e5cccSFangrui Song // CHECK:   ret i32 [[VGETQ_LANE]]
154*207e5cccSFangrui Song uint32_t test_vdups_laneq_u32(uint32x4_t a) {
155*207e5cccSFangrui Song   return vdups_laneq_u32(a, 3);
156*207e5cccSFangrui Song }
157*207e5cccSFangrui Song 
158*207e5cccSFangrui Song 
159*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i64 @test_vdupd_laneq_u64(<2 x i64> noundef %a) #0 {
160*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <2 x i64> %a, i32 1
161*207e5cccSFangrui Song // CHECK:   ret i64 [[VGETQ_LANE]]
162*207e5cccSFangrui Song uint64_t test_vdupd_laneq_u64(uint64x2_t a) {
163*207e5cccSFangrui Song   return vdupd_laneq_u64(a, 1);
164*207e5cccSFangrui Song }
165*207e5cccSFangrui Song 
166*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i8 @test_vdupb_lane_p8(<8 x i8> noundef %a) #0 {
167*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <8 x i8> %a, i32 7
168*207e5cccSFangrui Song // CHECK:   ret i8 [[VGET_LANE]]
169*207e5cccSFangrui Song poly8_t test_vdupb_lane_p8(poly8x8_t a) {
170*207e5cccSFangrui Song   return vdupb_lane_p8(a, 7);
171*207e5cccSFangrui Song }
172*207e5cccSFangrui Song 
173*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i16 @test_vduph_lane_p16(<4 x i16> noundef %a) #0 {
174*207e5cccSFangrui Song // CHECK:   [[VGET_LANE:%.*]] = extractelement <4 x i16> %a, i32 3
175*207e5cccSFangrui Song // CHECK:   ret i16 [[VGET_LANE]]
176*207e5cccSFangrui Song poly16_t test_vduph_lane_p16(poly16x4_t a) {
177*207e5cccSFangrui Song   return vduph_lane_p16(a, 3);
178*207e5cccSFangrui Song }
179*207e5cccSFangrui Song 
180*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i8 @test_vdupb_laneq_p8(<16 x i8> noundef %a) #0 {
181*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <16 x i8> %a, i32 15
182*207e5cccSFangrui Song // CHECK:   ret i8 [[VGETQ_LANE]]
183*207e5cccSFangrui Song poly8_t test_vdupb_laneq_p8(poly8x16_t a) {
184*207e5cccSFangrui Song   return vdupb_laneq_p8(a, 15);
185*207e5cccSFangrui Song }
186*207e5cccSFangrui Song 
187*207e5cccSFangrui Song // CHECK-LABEL: define{{.*}} i16 @test_vduph_laneq_p16(<8 x i16> noundef %a) #0 {
188*207e5cccSFangrui Song // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <8 x i16> %a, i32 7
189*207e5cccSFangrui Song // CHECK:   ret i16 [[VGETQ_LANE]]
190*207e5cccSFangrui Song poly16_t test_vduph_laneq_p16(poly16x8_t a) {
191*207e5cccSFangrui Song   return vduph_laneq_p16(a, 7);
192*207e5cccSFangrui Song }
193