1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
3 define <8 x i8> @test_vextd(ptr %A, ptr %B) nounwind {
4 ;CHECK-LABEL: test_vextd:
6 %tmp1 = load <8 x i8>, ptr %A
7 %tmp2 = load <8 x i8>, ptr %B
8 %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10>
12 define <8 x i8> @test_vextRd(ptr %A, ptr %B) nounwind {
13 ;CHECK-LABEL: test_vextRd:
14 ;CHECK: {{ext.8b.*#5}}
15 %tmp1 = load <8 x i8>, ptr %A
16 %tmp2 = load <8 x i8>, ptr %B
17 %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 13, i32 14, i32 15, i32 0, i32 1, i32 2, i32 3, i32 4>
21 define <16 x i8> @test_vextq(ptr %A, ptr %B) nounwind {
22 ;CHECK-LABEL: test_vextq:
23 ;CHECK: {{ext.16b.*3}}
24 %tmp1 = load <16 x i8>, ptr %A
25 %tmp2 = load <16 x i8>, ptr %B
26 %tmp3 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18>
30 define <16 x i8> @test_vextRq(ptr %A, ptr %B) nounwind {
31 ;CHECK-LABEL: test_vextRq:
32 ;CHECK: {{ext.16b.*7}}
33 %tmp1 = load <16 x i8>, ptr %A
34 %tmp2 = load <16 x i8>, ptr %B
35 %tmp3 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6>
39 define <4 x i16> @test_vextd16(ptr %A, ptr %B) nounwind {
40 ;CHECK-LABEL: test_vextd16:
41 ;CHECK: {{ext.8b.*#6}}
42 %tmp1 = load <4 x i16>, ptr %A
43 %tmp2 = load <4 x i16>, ptr %B
44 %tmp3 = shufflevector <4 x i16> %tmp1, <4 x i16> %tmp2, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
48 define <4 x i32> @test_vextq32(ptr %A, ptr %B) nounwind {
49 ;CHECK-LABEL: test_vextq32:
50 ;CHECK: {{ext.16b.*12}}
51 %tmp1 = load <4 x i32>, ptr %A
52 %tmp2 = load <4 x i32>, ptr %B
53 %tmp3 = shufflevector <4 x i32> %tmp1, <4 x i32> %tmp2, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
57 ; Undef shuffle indices should not prevent matching to VEXT:
59 define <8 x i8> @test_vextd_undef(ptr %A, ptr %B) nounwind {
60 ;CHECK-LABEL: test_vextd_undef:
62 %tmp1 = load <8 x i8>, ptr %A
63 %tmp2 = load <8 x i8>, ptr %B
64 %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 3, i32 undef, i32 undef, i32 6, i32 7, i32 8, i32 9, i32 10>
68 define <8 x i8> @test_vextd_undef2(ptr %A, ptr %B) nounwind {
69 ;CHECK-LABEL: test_vextd_undef2:
70 ;CHECK: {{ext.8b.*#6}}
71 %tmp1 = load <8 x i8>, ptr %A
72 %tmp2 = load <8 x i8>, ptr %B
73 %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 2, i32 3, i32 4, i32 5>
77 define <16 x i8> @test_vextRq_undef(ptr %A, ptr %B) nounwind {
78 ;CHECK-LABEL: test_vextRq_undef:
79 ;CHECK: {{ext.16b.*#7}}
80 %tmp1 = load <16 x i8>, ptr %A
81 %tmp2 = load <16 x i8>, ptr %B
82 %tmp3 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 23, i32 24, i32 25, i32 26, i32 undef, i32 undef, i32 29, i32 30, i32 31, i32 0, i32 1, i32 2, i32 3, i32 4, i32 undef, i32 6>
86 define <8 x i16> @test_vextRq_undef2(ptr %A) nounwind {
87 ;CHECK-LABEL: test_vextRq_undef2:
88 ;CHECK: {{ext.16b.*#10}}
89 %tmp1 = load <8 x i16>, ptr %A
90 %vext = shufflevector <8 x i16> %tmp1, <8 x i16> undef, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 1, i32 2, i32 3, i32 4>
94 ; Tests for ReconstructShuffle function. Indices have to be carefully
95 ; chosen to reach lowering phase as a BUILD_VECTOR.
97 ; An undef in the shuffle list should still be optimizable
98 define <4 x i16> @test_undef(ptr %A, ptr %B) nounwind {
99 ;CHECK-LABEL: test_undef:
101 %tmp1 = load <8 x i16>, ptr %A
102 %tmp2 = load <8 x i16>, ptr %B
103 %tmp3 = shufflevector <8 x i16> %tmp1, <8 x i16> %tmp2, <4 x i32> <i32 undef, i32 8, i32 5, i32 9>