xref: /llvm-project/clang/test/CodeGen/arm64_vcopy.c (revision 0d501f38f348cf046d40c9baee12f0c5145b6d8c)
1 // RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -o - -disable-O0-optnone -emit-llvm %s | opt -S -passes=mem2reg | FileCheck %s
2 
3 // Test ARM64 SIMD copy vector element to vector element: vcopyq_lane*
4 
5 // REQUIRES: aarch64-registered-target || arm-registered-target
6 
7 #include <arm_neon.h>
8 
9 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vcopyq_laneq_s8(<16 x i8> noundef %a1, <16 x i8> noundef %a2) #0 {
10 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <16 x i8> %a2, i32 13
11 // CHECK:   [[VSET_LANE:%.*]] = insertelement <16 x i8> %a1, i8 [[VGETQ_LANE]], i32 3
12 // CHECK:   ret <16 x i8> [[VSET_LANE]]
test_vcopyq_laneq_s8(int8x16_t a1,int8x16_t a2)13 int8x16_t test_vcopyq_laneq_s8(int8x16_t a1, int8x16_t a2) {
14   return vcopyq_laneq_s8(a1, (int64_t) 3, a2, (int64_t) 13);
15 }
16 
17 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vcopyq_laneq_u8(<16 x i8> noundef %a1, <16 x i8> noundef %a2) #0 {
18 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <16 x i8> %a2, i32 13
19 // CHECK:   [[VSET_LANE:%.*]] = insertelement <16 x i8> %a1, i8 [[VGETQ_LANE]], i32 3
20 // CHECK:   ret <16 x i8> [[VSET_LANE]]
test_vcopyq_laneq_u8(uint8x16_t a1,uint8x16_t a2)21 uint8x16_t test_vcopyq_laneq_u8(uint8x16_t a1, uint8x16_t a2) {
22   return vcopyq_laneq_u8(a1, (int64_t) 3, a2, (int64_t) 13);
23 
24 }
25 
26 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vcopyq_laneq_s16(<8 x i16> noundef %a1, <8 x i16> noundef %a2) #0 {
27 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <8 x i16> %a2, i32 7
28 // CHECK:   [[VSET_LANE:%.*]] = insertelement <8 x i16> %a1, i16 [[VGETQ_LANE]], i32 3
29 // CHECK:   ret <8 x i16> [[VSET_LANE]]
test_vcopyq_laneq_s16(int16x8_t a1,int16x8_t a2)30 int16x8_t test_vcopyq_laneq_s16(int16x8_t a1, int16x8_t a2) {
31   return vcopyq_laneq_s16(a1, (int64_t) 3, a2, (int64_t) 7);
32 
33 }
34 
35 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vcopyq_laneq_u16(<8 x i16> noundef %a1, <8 x i16> noundef %a2) #0 {
36 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <8 x i16> %a2, i32 7
37 // CHECK:   [[VSET_LANE:%.*]] = insertelement <8 x i16> %a1, i16 [[VGETQ_LANE]], i32 3
38 // CHECK:   ret <8 x i16> [[VSET_LANE]]
test_vcopyq_laneq_u16(uint16x8_t a1,uint16x8_t a2)39 uint16x8_t test_vcopyq_laneq_u16(uint16x8_t a1, uint16x8_t a2) {
40   return vcopyq_laneq_u16(a1, (int64_t) 3, a2, (int64_t) 7);
41 
42 }
43 
44 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vcopyq_laneq_s32(<4 x i32> noundef %a1, <4 x i32> noundef %a2) #0 {
45 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <4 x i32> %a2, i32 3
46 // CHECK:   [[VSET_LANE:%.*]] = insertelement <4 x i32> %a1, i32 [[VGETQ_LANE]], i32 3
47 // CHECK:   ret <4 x i32> [[VSET_LANE]]
test_vcopyq_laneq_s32(int32x4_t a1,int32x4_t a2)48 int32x4_t test_vcopyq_laneq_s32(int32x4_t a1, int32x4_t a2) {
49   return vcopyq_laneq_s32(a1, (int64_t) 3, a2, (int64_t) 3);
50 }
51 
52 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vcopyq_laneq_u32(<4 x i32> noundef %a1, <4 x i32> noundef %a2) #0 {
53 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <4 x i32> %a2, i32 3
54 // CHECK:   [[VSET_LANE:%.*]] = insertelement <4 x i32> %a1, i32 [[VGETQ_LANE]], i32 3
55 // CHECK:   ret <4 x i32> [[VSET_LANE]]
test_vcopyq_laneq_u32(uint32x4_t a1,uint32x4_t a2)56 uint32x4_t test_vcopyq_laneq_u32(uint32x4_t a1, uint32x4_t a2) {
57   return vcopyq_laneq_u32(a1, (int64_t) 3, a2, (int64_t) 3);
58 }
59 
60 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcopyq_laneq_s64(<2 x i64> noundef %a1, <2 x i64> noundef %a2) #0 {
61 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <2 x i64> %a2, i32 1
62 // CHECK:   [[VSET_LANE:%.*]] = insertelement <2 x i64> %a1, i64 [[VGETQ_LANE]], i32 0
63 // CHECK:   ret <2 x i64> [[VSET_LANE]]
test_vcopyq_laneq_s64(int64x2_t a1,int64x2_t a2)64 int64x2_t test_vcopyq_laneq_s64(int64x2_t a1, int64x2_t a2) {
65   return vcopyq_laneq_s64(a1, (int64_t) 0, a2, (int64_t) 1);
66 }
67 
68 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcopyq_laneq_u64(<2 x i64> noundef %a1, <2 x i64> noundef %a2) #0 {
69 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <2 x i64> %a2, i32 1
70 // CHECK:   [[VSET_LANE:%.*]] = insertelement <2 x i64> %a1, i64 [[VGETQ_LANE]], i32 0
71 // CHECK:   ret <2 x i64> [[VSET_LANE]]
test_vcopyq_laneq_u64(uint64x2_t a1,uint64x2_t a2)72 uint64x2_t test_vcopyq_laneq_u64(uint64x2_t a1, uint64x2_t a2) {
73   return vcopyq_laneq_u64(a1, (int64_t) 0, a2, (int64_t) 1);
74 }
75 
76 // CHECK-LABEL: define{{.*}} <4 x float> @test_vcopyq_laneq_f32(<4 x float> noundef %a1, <4 x float> noundef %a2) #0 {
77 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <4 x float> %a2, i32 3
78 // CHECK:   [[VSET_LANE:%.*]] = insertelement <4 x float> %a1, float [[VGETQ_LANE]], i32 0
79 // CHECK:   ret <4 x float> [[VSET_LANE]]
test_vcopyq_laneq_f32(float32x4_t a1,float32x4_t a2)80 float32x4_t test_vcopyq_laneq_f32(float32x4_t a1, float32x4_t a2) {
81   return vcopyq_laneq_f32(a1, 0, a2, 3);
82 }
83 
84 // CHECK-LABEL: define{{.*}} <2 x double> @test_vcopyq_laneq_f64(<2 x double> noundef %a1, <2 x double> noundef %a2) #0 {
85 // CHECK:   [[VGETQ_LANE:%.*]] = extractelement <2 x double> %a2, i32 1
86 // CHECK:   [[VSET_LANE:%.*]] = insertelement <2 x double> %a1, double [[VGETQ_LANE]], i32 0
87 // CHECK:   ret <2 x double> [[VSET_LANE]]
test_vcopyq_laneq_f64(float64x2_t a1,float64x2_t a2)88 float64x2_t test_vcopyq_laneq_f64(float64x2_t a1, float64x2_t a2) {
89   return vcopyq_laneq_f64(a1, 0, a2, 1);
90 }
91 
92