[AArch64] Robustize neon-scalar-copy.ll tests. NFC.
[oota-llvm.git] / test / CodeGen / AArch64 / neon-scalar-copy.ll
1 ; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+neon -asm-verbose=false < %s | FileCheck %s
2
3 define float @test_dup_sv2S(<2 x float> %v) #0 {
4  ; CHECK-LABEL: test_dup_sv2S:
5  ; CHECK-NEXT: ins {{v[0-9]+}}.s[0], {{v[0-9]+}}.s[1]
6  ; CHECK-NEXT: ret
7  %tmp1 = extractelement <2 x float> %v, i32 1
8  ret float  %tmp1
9 }
10
11 define float @test_dup_sv2S_0(<2 x float> %v) #0 {
12  ; CHECK-LABEL: test_dup_sv2S_0:
13  ; CHECK-NOT: dup {{[vsd][0-9]+}}
14  ; CHECK-NOT: ins {{[vsd][0-9]+}}
15  ; CHECK-NEXT: ret
16  %tmp1 = extractelement <2 x float> %v, i32 0
17  ret float  %tmp1
18 }
19
20 define float @test_dup_sv4S(<4 x float> %v) #0 {
21  ; CHECK-LABEL: test_dup_sv4S:
22  ; CHECK-NOT: dup {{[vsd][0-9]+}}
23  ; CHECK-NOT: ins {{[vsd][0-9]+}}
24  ; CHECK-NEXT: ret
25  %tmp1 = extractelement <4 x float> %v, i32 0
26  ret float  %tmp1
27 }
28
29 define double @test_dup_dvD(<1 x double> %v) #0 {
30  ; CHECK-LABEL: test_dup_dvD:
31  ; CHECK-NOT: dup {{[vsd][0-9]+}}
32  ; CHECK-NOT: ins {{[vsd][0-9]+}}
33  ; CHECK-NEXT: ret
34  %tmp1 = extractelement <1 x double> %v, i32 0
35  ret double  %tmp1
36 }
37
38 define double @test_dup_dv2D(<2 x double> %v) #0 {
39  ; CHECK-LABEL: test_dup_dv2D:
40  ; CHECK-NEXT: ins {{v[0-9]+}}.d[0], {{v[0-9]+}}.d[1]
41  ; CHECK-NEXT: ret
42  %tmp1 = extractelement <2 x double> %v, i32 1
43  ret double  %tmp1
44 }
45
46 define double @test_dup_dv2D_0(<2 x double> %v) #0 {
47  ; CHECK-LABEL: test_dup_dv2D_0:
48  ; CHECK-NEXT: ins {{v[0-9]+}}.d[0], {{v[0-9]+}}.d[1]
49  ; CHECK-NEXT: ret
50  %tmp1 = extractelement <2 x double> %v, i32 1
51  ret double  %tmp1
52 }
53
54 define <1 x i8> @test_vector_dup_bv16B(<16 x i8> %v1) #0 {
55  ; CHECK-LABEL: test_vector_dup_bv16B:
56  ; CHECK-NEXT: umov [[W:w[0-9]+]], v0.b[14]
57  ; CHECK-NEXT: fmov s0, [[W]]
58  ; CHECK-NEXT: ret
59  %shuffle.i = shufflevector <16 x i8> %v1, <16 x i8> undef, <1 x i32> <i32 14> 
60  ret <1 x i8> %shuffle.i
61 }
62
63 define <1 x i8> @test_vector_dup_bv8B(<8 x i8> %v1) #0 {
64  ; CHECK-LABEL: test_vector_dup_bv8B:
65  ; CHECK-NEXT: dup v0.8b, v0.b[7]
66  ; CHECK-NEXT: ret
67  %shuffle.i = shufflevector <8 x i8> %v1, <8 x i8> undef, <1 x i32> <i32 7> 
68  ret <1 x i8> %shuffle.i
69 }
70
71 define <1 x i16> @test_vector_dup_hv8H(<8 x i16> %v1) #0 {
72  ; CHECK-LABEL: test_vector_dup_hv8H:
73  ; CHECK-NEXT: umov [[W:w[0-9]+]], v0.h[7]
74  ; CHECK-NEXT: fmov s0, [[W]]
75  ; CHECK-NEXT: ret
76  %shuffle.i = shufflevector <8 x i16> %v1, <8 x i16> undef, <1 x i32> <i32 7> 
77  ret <1 x i16> %shuffle.i
78 }
79
80 define <1 x i16> @test_vector_dup_hv4H(<4 x i16> %v1) #0 {
81  ; CHECK-LABEL: test_vector_dup_hv4H:
82  ; CHECK-NEXT: dup v0.4h, v0.h[3]
83  ; CHECK-NEXT: ret
84  %shuffle.i = shufflevector <4 x i16> %v1, <4 x i16> undef, <1 x i32> <i32 3> 
85  ret <1 x i16> %shuffle.i
86 }
87
88 define <1 x i32> @test_vector_dup_sv4S(<4 x i32> %v1) #0 {
89  ; CHECK-LABEL: test_vector_dup_sv4S:
90  ; CHECK-NEXT: mov  [[W:w[0-9]+]], v0.s[3]
91  ; CHECK-NEXT: fmov s0, [[W]]
92  ; CHECK-NEXT: ret
93  %shuffle = shufflevector <4 x i32> %v1, <4 x i32> undef, <1 x i32> <i32 3> 
94  ret <1 x i32> %shuffle
95 }
96
97 define <1 x i32> @test_vector_dup_sv2S(<2 x i32> %v1) #0 {
98  ; CHECK-LABEL: test_vector_dup_sv2S:
99  ; CHECK-NEXT: dup v0.2s, v0.s[1]
100  ; CHECK-NEXT: ret
101  %shuffle = shufflevector <2 x i32> %v1, <2 x i32> undef, <1 x i32> <i32 1> 
102  ret <1 x i32> %shuffle
103 }
104
105 define <1 x i64> @test_vector_dup_dv2D(<2 x i64> %v1) #0 {
106  ; CHECK-LABEL: test_vector_dup_dv2D:
107  ; CHECK-NEXT: ext {{v[0-9]+}}.16b, {{v[0-9]+}}.16b, {{v[0-9]+}}.16b, #8
108  ; CHECK-NEXT: ret
109  %shuffle.i = shufflevector <2 x i64> %v1, <2 x i64> undef, <1 x i32> <i32 1> 
110  ret <1 x i64> %shuffle.i
111 }
112
113 define <1 x i64> @test_vector_copy_dup_dv2D(<1 x i64> %a, <2 x i64> %c) #0 {
114   ; CHECK-LABEL: test_vector_copy_dup_dv2D:
115   ; CHECK-NEXT: {{dup|mov}} {{d[0-9]+}}, {{v[0-9]+}}.d[1]
116   ; CHECK-NEXT: ret
117   %vget_lane = extractelement <2 x i64> %c, i32 1
118   %vset_lane = insertelement <1 x i64> undef, i64 %vget_lane, i32 0
119   ret <1 x i64> %vset_lane
120 }
121
122 ; Undefined behaviour, so we really don't care what actually gets emitted, just
123 ; as long as we don't crash (since it could be dynamically unreachable).
124 define i32 @test_out_of_range_extract(<4 x i32> %vec) {
125 ; CHECK-LABEL: test_out_of_range_extract:
126 ; CHECK: ret
127   %elt = extractelement <4 x i32> %vec, i32 4
128   ret i32 %elt
129 }
130
131 ; Undefined behaviour, so we really don't care what actually gets emitted, just
132 ; as long as we don't crash (since it could be dynamically unreachable).
133 define void @test_out_of_range_insert(<4 x i32> %vec, i32 %elt) {
134 ; CHECK-LABEL: test_out_of_range_insert:
135 ; CHECK: ret
136   insertelement <4 x i32> %vec, i32 %elt, i32 4
137   ret void
138 }
139
140 attributes #0 = { nounwind }