1; RUN: llc -march=hexagon < %s
2; Used to fail with an infinite recursion in the insn selection.
3target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32"
4target triple = "hexagon-unknown-linux-gnu"
5
6%struct.elt = type { [2 x [4 x %struct.block]] }
7%struct.block = type { [2 x i16] }
8
9define void @foo(%struct.elt* noalias nocapture %p0, %struct.elt* noalias nocapture %p1) nounwind {
10entry:
11  %arrayidx1 = getelementptr inbounds %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 3
12  %arrayidx4 = getelementptr inbounds %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 2
13  %arrayidx7 = getelementptr inbounds %struct.elt, %struct.elt* %p0, i32 0, i32 0, i32 0, i32 3
14  %0 = bitcast %struct.block* %arrayidx7 to i32*
15  %1 = bitcast %struct.block* %arrayidx4 to i32*
16  %2 = load i32, i32* %0, align 4
17  store i32 %2, i32* %1, align 4
18  %3 = bitcast %struct.block* %arrayidx1 to i32*
19  store i32 %2, i32* %3, align 4
20  %arrayidx10 = getelementptr inbounds %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 1
21  %arrayidx16 = getelementptr inbounds %struct.elt, %struct.elt* %p0, i32 0, i32 0, i32 0, i32 2
22  %4 = bitcast %struct.block* %arrayidx16 to i32*
23  %5 = bitcast %struct.elt* %p1 to i32*
24  %6 = load i32, i32* %4, align 4
25  store i32 %6, i32* %5, align 4
26  %7 = bitcast %struct.block* %arrayidx10 to i32*
27  store i32 %6, i32* %7, align 4
28  %p_arrayidx26 = getelementptr %struct.elt, %struct.elt* %p0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1
29  %p_arrayidx2632 = getelementptr %struct.elt, %struct.elt* %p0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 1
30  %p_arrayidx2633 = getelementptr %struct.elt, %struct.elt* %p0, i32 0, i32 0, i32 0, i32 2, i32 0, i32 1
31  %p_arrayidx2634 = getelementptr %struct.elt, %struct.elt* %p0, i32 0, i32 0, i32 0, i32 3, i32 0, i32 1
32  %p_arrayidx20 = getelementptr %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1
33  %p_arrayidx2035 = getelementptr %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 1
34  %p_arrayidx2036 = getelementptr %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 2, i32 0, i32 1
35  %p_arrayidx2037 = getelementptr %struct.elt, %struct.elt* %p1, i32 0, i32 0, i32 0, i32 3, i32 0, i32 1
36  %8 = lshr i32 %6, 16
37  %9 = trunc i32 %8 to i16
38  %_p_vec_ = insertelement <4 x i16> undef, i16 %9, i32 0
39  %_p_vec_39 = insertelement <4 x i16> %_p_vec_, i16 %9, i32 1
40  %10 = lshr i32 %2, 16
41  %11 = trunc i32 %10 to i16
42  %_p_vec_41 = insertelement <4 x i16> %_p_vec_39, i16 %11, i32 2
43  %_p_vec_43 = insertelement <4 x i16> %_p_vec_41, i16 %11, i32 3
44  %shlp_vec = shl <4 x i16> %_p_vec_43, <i16 1, i16 1, i16 1, i16 1>
45  %12 = extractelement <4 x i16> %shlp_vec, i32 0
46  store i16 %12, i16* %p_arrayidx20, align 2
47  %13 = extractelement <4 x i16> %shlp_vec, i32 1
48  store i16 %13, i16* %p_arrayidx2035, align 2
49  %14 = extractelement <4 x i16> %shlp_vec, i32 2
50  store i16 %14, i16* %p_arrayidx2036, align 2
51  %15 = extractelement <4 x i16> %shlp_vec, i32 3
52  store i16 %15, i16* %p_arrayidx2037, align 2
53  %_p_scalar_44 = load i16, i16* %p_arrayidx26, align 2
54  %_p_vec_45 = insertelement <4 x i16> undef, i16 %_p_scalar_44, i32 0
55  %_p_scalar_46 = load i16, i16* %p_arrayidx2632, align 2
56  %_p_vec_47 = insertelement <4 x i16> %_p_vec_45, i16 %_p_scalar_46, i32 1
57  %_p_scalar_48 = load i16, i16* %p_arrayidx2633, align 2
58  %_p_vec_49 = insertelement <4 x i16> %_p_vec_47, i16 %_p_scalar_48, i32 2
59  %_p_scalar_50 = load i16, i16* %p_arrayidx2634, align 2
60  %_p_vec_51 = insertelement <4 x i16> %_p_vec_49, i16 %_p_scalar_50, i32 3
61  %shl28p_vec = shl <4 x i16> %_p_vec_51, <i16 1, i16 1, i16 1, i16 1>
62  %16 = extractelement <4 x i16> %shl28p_vec, i32 0
63  store i16 %16, i16* %p_arrayidx26, align 2
64  %17 = extractelement <4 x i16> %shl28p_vec, i32 1
65  store i16 %17, i16* %p_arrayidx2632, align 2
66  %18 = extractelement <4 x i16> %shl28p_vec, i32 2
67  store i16 %18, i16* %p_arrayidx2633, align 2
68  %19 = extractelement <4 x i16> %shl28p_vec, i32 3
69  store i16 %19, i16* %p_arrayidx2634, align 2
70  ret void
71}
72