1; RUN: opt < %s -mtriple=arm-eabi -mattr=+neon -interleaved-access -S | FileCheck %s
2
3; CHECK-LABEL: @extract_user_basic(
4; CHECK: %vldN = call { <4 x i32>, <4 x i32> } @llvm.arm.neon.vld2.v4i32.p0i8
5; CHECK: %[[R:.+]] = extractvalue { <4 x i32>, <4 x i32> } %vldN, 0
6; CHECK: extractelement <4 x i32> %[[R]], i64 1
7define void @extract_user_basic(<8 x i32>* %A, i1 %C) {
8entry:
9  %L = load <8 x i32>, <8 x i32>* %A, align 8
10  %S = shufflevector <8 x i32> %L, <8 x i32> undef, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
11  br i1 %C, label %if.then, label %if.merge
12
13if.then:
14  %E = extractelement <8 x i32> %L, i32 2
15  br label %if.merge
16
17if.merge:
18  ret void
19}
20
21; CHECK-LABEL: @extract_user_multi(
22; CHECK: %vldN = call { <4 x i32>, <4 x i32> } @llvm.arm.neon.vld2.v4i32.p0i8
23; CHECK: %[[R:.+]] = extractvalue { <4 x i32>, <4 x i32> } %vldN, 0
24; CHECK: extractelement <4 x i32> %[[R]], i64 0
25; CHECK: extractelement <4 x i32> %[[R]], i64 1
26define void @extract_user_multi(<8 x i32>* %A, i1 %C) {
27entry:
28  %L = load <8 x i32>, <8 x i32>* %A, align 8
29  %S = shufflevector <8 x i32> %L, <8 x i32> undef, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
30  br i1 %C, label %if.then, label %if.merge
31
32if.then:
33  %E1 = extractelement <8 x i32> %L, i32 0
34  br label %if.merge
35
36if.merge:
37  %E2 = extractelement <8 x i32> %L, i32 2
38  ret void
39}
40
41; CHECK-LABEL: @extract_user_multi_no_dom(
42; CHECK-NOT: %vldN = call { <4 x i32>, <4 x i32> } @llvm.arm.neon.vld2.v4i32.p0i8
43define void @extract_user_multi_no_dom(<8 x i32>* %A, i1 %C) {
44entry:
45  %L = load <8 x i32>, <8 x i32>* %A, align 8
46  %E1 = extractelement <8 x i32> %L, i32 0
47  br i1 %C, label %if.then, label %if.merge
48
49if.then:
50  %S = shufflevector <8 x i32> %L, <8 x i32> undef, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
51  %E2 = extractelement <8 x i32> %L, i32 2
52  br label %if.merge
53
54if.merge:
55  ret void
56}
57
58; CHECK-LABEL: @extract_user_wrong_const_index(
59; CHECK-NOT: %vldN = call { <4 x i32>, <4 x i32> } @llvm.arm.neon.vld2.v4i32.p0i8
60define void @extract_user_wrong_const_index(<8 x i32>* %A) {
61entry:
62  %L = load <8 x i32>, <8 x i32>* %A, align 8
63  %S = shufflevector <8 x i32> %L, <8 x i32> undef, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
64  %E = extractelement <8 x i32> %L, i32 1
65  ret void
66}
67
68; CHECK-LABEL: @extract_user_undef_index(
69; CHECK-NOT: %vldN = call { <4 x i32>, <4 x i32> } @llvm.arm.neon.vld2.v4i32.p0i8
70define void @extract_user_undef_index(<8 x i32>* %A) {
71entry:
72  %L = load <8 x i32>, <8 x i32>* %A, align 8
73  %S = shufflevector <8 x i32> %L, <8 x i32> undef, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
74  %E = extractelement <8 x i32> %L, i32 undef
75  ret void
76}
77
78; CHECK-LABEL: @extract_user_var_index(
79; CHECK-NOT: %vldN = call { <4 x i32>, <4 x i32> } @llvm.arm.neon.vld2.v4i32.p0i8
80define void @extract_user_var_index(<8 x i32>* %A, i32 %I) {
81entry:
82  %L = load <8 x i32>, <8 x i32>* %A, align 8
83  %S = shufflevector <8 x i32> %L, <8 x i32> undef, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
84  %E = extractelement <8 x i32> %L, i32 %I
85  ret void
86}
87