1; Tests malformed insertelement and extractelement vector instructions.
2
3; RUN: %if --need=allow_dump --command \
4; RUN:   %p2i --expect-fail -i %s --allow-pnacl-reader-error-recovery \
5; RUN:   --filetype=obj -o /dev/null --args -notranslate \
6; RUN:   | %if --need=allow_dump --command FileCheck %s
7
8; RUN: %if --need=no_dump --command \
9; RUN:   %p2i --expect-fail -i %s --allow-pnacl-reader-error-recovery \
10; RUN:   --filetype=obj -o /dev/null --args -notranslate \
11; RUN:   | %if --need=no_dump --command FileCheck %s --check-prefix=MIN
12
13define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
14  %e0 = extractelement <4 x i1> %v, i32 %i
15; CHECK: Error{{.*}} not {{.*}} constant
16; MIN: Error{{.*}} Invalid function record: <6 4 3>
17  %e1 = extractelement <4 x i1> %v, i32 4
18; CHECK: Error{{.*}} not in range
19; MIN: Error{{.*}} Invalid function record: <6 5 3>
20  %e2 = extractelement <4 x i1> %v, i32 9
21; CHECK: Error{{.*}} not in range
22; MIN: Error{{.*}} Invalid function record:  <6 6 3>
23  ret void
24}
25
26define void @ExtractV8xi1(<8 x i1> %v, i32 %i) {
27  %e0 = extractelement <8 x i1> %v, i32 %i
28; CHECK: Error{{.*}} not {{.*}} constant
29; MIN: Error{{.*}} Invalid function record: <6 4 3>
30  %e1 = extractelement <8 x i1> %v, i32 8;
31; CHECK: Error{{.*}} not in range
32; MIN: Error{{.*}} Invalid function record: <6 5 3>
33  %e2 = extractelement <8 x i1> %v, i32 9;
34; CHECK: Error{{.*}} not in range
35; MIN: Error{{.*}} Invalid function record: <6 6 3>
36  ret void
37}
38
39define void @ExtractV16xi1(<16 x i1> %v, i32 %i) {
40  %e0 = extractelement <16 x i1> %v, i32 %i
41; CHECK: Error{{.*}} not {{.*}} constant
42; MIN: Error{{.*}} Invalid function record: <6 4 3>
43  %e1 = extractelement <16 x i1> %v, i32 16
44; CHECK: Error{{.*}} not in range
45; MIN: Error{{.*}} Invalid function record: <6 5 3>
46  %e2 = extractelement <16 x i1> %v, i32 24
47; CHECK: Error{{.*}} not in range
48; MIN: Error{{.*}} Invalid function record: <6 6 3>
49  ret void
50}
51
52define void @ExtractV16xi8(<16 x i8> %v, i32 %i) {
53  %e0 = extractelement <16 x i8> %v, i32 %i
54; CHECK: Error{{.*}} not {{.*}} constant
55; MIN: Error{{.*}} Invalid function record: <6 4 3>
56  %e1 = extractelement <16 x i8> %v, i32 16
57; CHECK: Error{{.*}} not in range
58; MIN: Error{{.*}} Invalid function record: <6 5 3>
59  %e2 = extractelement <16 x i8> %v, i32 71
60; CHECK: Error{{.*}} not in range
61; MIN: Error{{.*}} Invalid function record: <6 6 3>
62  ret void
63}
64
65define void @ExtractV8xi16(<8 x i16> %v, i32 %i) {
66  %e0 = extractelement <8 x i16> %v, i32 %i
67; CHECK: Error{{.*}} not {{.*}} constant
68; MIN: Error{{.*}} Invalid function record: <6 4 3>
69  %e1 = extractelement <8 x i16> %v, i32 8
70; CHECK: Error{{.*}} not in range
71; MIN: Error{{.*}} Invalid function record: <6 5 3>
72  %e2 = extractelement <8 x i16> %v, i32 15
73; CHECK: Error{{.*}} not in range
74; MIN: Error{{.*}} Invalid function record: <6 6 3>
75  ret void
76}
77
78define i32 @ExtractV4xi32(<4 x i32> %v, i32 %i) {
79  %e0 = extractelement <4 x i32> %v, i32 %i
80; CHECK: Error{{.*}} not {{.*}} constant
81; MIN: Error{{.*}} Invalid function record: <6 4 3>
82  %e1 = extractelement <4 x i32> %v, i32 4
83; CHECK: Error{{.*}} not in range
84; MIN: Error{{.*}} Invalid function record: <6 5 3>
85  %e2 = extractelement <4 x i32> %v, i32 17
86; CHECK: Error{{.*}} not in range
87; MIN: Error{{.*}} Invalid function record: <6 6 3>
88  ret i32 %e0
89}
90
91define float @ExtractV4xfloat(<4 x float> %v, i32 %i) {
92  %e0 = extractelement <4 x float> %v, i32 %i
93; CHECK: Error{{.*}} not {{.*}} constant
94; MIN: Error{{.*}} Invalid function record: <6 3 2>
95  %e1 = extractelement <4 x float> %v, i32 4
96; CHECK: Error{{.*}} not in range
97; MIN: Error{{.*}} Invalid function record: <6 4 2>
98  %e2 = extractelement <4 x float> %v, i32 4
99; CHECK: Error{{.*}} not in range
100; MIN: Error{{.*}} Invalid function record: <6 5 3>
101  ret float %e2
102}
103
104define <4 x i1> @InsertV4xi1(<4 x i1> %v, i32 %i) {
105  %r0 = insertelement <4 x i1> %v, i1 1, i32 %i
106; CHECK: Error{{.*}} not {{.*}} constant
107; MIN: Error{{.*}} Invalid function record: <7 5 1 4>
108  %r1 = insertelement <4 x i1> %v, i1 1, i32 4
109; CHECK: Error{{.*}} not in range
110; MIN: Error{{.*}} Invalid function record: <7 6 2 4>
111  %r2 = insertelement <4 x i1> %v, i1 1, i32 7
112; CHECK: Error{{.*}} not in range
113; MIN: Error{{.*}} Invalid function record: <7 7 3 4>
114  ret <4 x i1> %r2
115}
116
117define <8 x i1> @InsertV8xi1(<8 x i1> %v, i32 %i) {
118  %r0 = insertelement <8 x i1> %v, i1 0, i32 %i
119; CHECK: Error{{.*}} not {{.*}} constant
120; MIN: Error{{.*}} Invalid function record: <7 5 1 4>
121  %r1 = insertelement <8 x i1> %v, i1 0, i32 8
122; CHECK: Error{{.*}} not in range
123; MIN: Error{{.*}} Invalid function record: <7 6 2 4>
124  %r2 = insertelement <8 x i1> %v, i1 0, i32 88
125; CHECK: Error{{.*}} not in range
126; MIN: Error{{.*}} Invalid function record: <7 7 3 4>
127  ret <8 x i1> %r2
128}
129
130define <16 x i1> @InsertV16xi1(<16 x i1> %v, i32 %i) {
131  %r = insertelement <16 x i1> %v, i1 1, i32 %i
132; CHECK: Error{{.*}} not {{.*}} constant
133; MIN: Error{{.*}} Invalid function record: <7 5 1 4>
134  ret <16 x i1> %r
135  %r1 = insertelement <16 x i1> %v, i1 1, i32 16
136; CHECK: Error{{.*}} not in range
137; MIN: Error{{.*}} Invalid function record: <7 6 2 4>
138  %r2 = insertelement <16 x i1> %v, i1 1, i32 31
139; CHECK: Error{{.*}} not in range
140; MIN: Error{{.*}} Invalid function record: <7 7 3 4>
141  ret <16 x i1> %r2
142}
143
144define <16 x i8> @InsertV16xi8(<16 x i8> %v, i32 %i) {
145  %r0 = insertelement <16 x i8> %v, i8 34, i32 %i
146; CHECK: Error{{.*}} not {{.*}} constant
147; MIN: Error{{.*}} Invalid function record: <7 5 1 4>
148  %r1 = insertelement <16 x i8> %v, i8 34, i32 16
149; CHECK: Error{{.*}} not in range
150; MIN: Error{{.*}} Invalid function record: <7 6 2 4>
151  %r2 = insertelement <16 x i8> %v, i8 34, i32 19
152; CHECK: Error{{.*}} not in range
153; MIN: Error{{.*}} Invalid function record: <7 7 3 4>
154  ret <16 x i8> %r0
155}
156
157define <8 x i16> @InsertV8xi16(<8 x i16> %v, i32 %i) {
158  %r0 = insertelement <8 x i16> %v, i16 289, i32 %i
159; CHECK: Error{{.*}} not {{.*}} constant
160; MIN: Error{{.*}} Invalid function record: <7 5 1 4>
161  %r1 = insertelement <8 x i16> %v, i16 289, i32 8
162; CHECK: Error{{.*}} not in range
163; MIN: Error{{.*}} Invalid function record: <7 6 2 4>
164  %r2 = insertelement <8 x i16> %v, i16 289, i32 19
165; CHECK: Error{{.*}} not in range
166; MIN: Error{{.*}} Invalid function record: <7 7 3 4>
167  ret <8 x i16> %r1
168}
169
170define <4 x i32> @InsertV4xi32(<4 x i32> %v, i32 %i) {
171  %r0 = insertelement <4 x i32> %v, i32 54545454, i32 %i
172; CHECK: Error{{.*}} not {{.*}} constant
173; MIN: Error{{.*}} Invalid function record: <7 5 3 4>
174  %r1 = insertelement <4 x i32> %v, i32 54545454, i32 4
175; CHECK: Error{{.*}} not in range
176; MIN: Error{{.*}} Invalid function record: <7 6 4 3>
177  %r2 = insertelement <4 x i32> %v, i32 54545454, i32 9
178; CHECK: Error{{.*}} not in range
179; MIN: Error{{.*}} Invalid function record: <7 7 5 3>
180  ret <4 x i32> %r2
181}
182
183define <4 x float> @InsertV4xfloat(<4 x float> %v, i32 %i) {
184  %r0 = insertelement <4 x float> %v, float 3.0, i32 %i
185; CHECK: Error{{.*}} not {{.*}} constant
186; MIN: Error{{.*}} Invalid function record: <7 5 1 4>
187  %r1 = insertelement <4 x float> %v, float 3.0, i32 4
188; CHECK: Error{{.*}} not in range
189; MIN: Error{{.*}} Invalid function record: <7 6 2 4>
190  %r2 = insertelement <4 x float> %v, float 3.0, i32 44
191; CHECK: Error{{.*}} not in range
192; MIN: Error{{.*}} Invalid function record: <7 7 3 4>
193  ret <4 x float> %r2
194}
195