1; RUN: llc -march=hexagon -O2 < %s -pipeliner-experimental-cg=true | FileCheck %s
2
3; We do not pipeline sigma yet, but the non-pipelined version
4; with good scheduling is pretty fast. The compiler generates
5; 18 packets, and the assembly version is 16.
6
7; CHECK:  loop0(.LBB0_[[LOOP:.]],
8; CHECK: .LBB0_[[LOOP]]:
9; CHECK-COUNT-17: }
10; CHECK: }{{[ \t]*}}:endloop
11
12@g0 = external constant [10 x i16], align 128
13
14declare i32 @llvm.hexagon.S2.vsplatrb(i32) #0
15declare <16 x i32> @llvm.hexagon.V6.vshuffh(<16 x i32>) #0
16declare <16 x i32> @llvm.hexagon.V6.lvsplatw(i32) #0
17declare <16 x i32> @llvm.hexagon.V6.vd0() #0
18declare <32 x i32> @llvm.hexagon.V6.vsububh(<16 x i32>, <16 x i32>) #0
19declare <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32>, <16 x i32>) #0
20declare <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32>, <16 x i32>) #0
21declare <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1>, <16 x i32>, <16 x i32>) #0
22declare <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1>, <16 x i32>, <16 x i32>) #0
23declare <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32>, <16 x i32>) #0
24declare <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32>, <32 x i32>, i32) #0
25declare <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32>, <16 x i32>, i32) #0
26declare <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32>, <16 x i32>, i32) #0
27declare <32 x i32> @llvm.hexagon.V6.vlutvwh(<16 x i32>, <16 x i32>, i32) #0
28declare <16 x i32> @llvm.hexagon.V6.vmpyhvsrs(<16 x i32>, <16 x i32>) #0
29declare <16 x i32> @llvm.hexagon.V6.lo(<32 x i32>) #0
30declare <16 x i32> @llvm.hexagon.V6.hi(<32 x i32>) #0
31declare <16 x i32> @llvm.hexagon.V6.vsathub(<16 x i32>, <16 x i32>) #0
32
33define void @f0(i8* nocapture readonly %a0, i32 %a1, i32 %a2, i32 %a3, i8 zeroext %a4, i8* nocapture %a5) #1 {
34b0:
35  %v0 = add nsw i32 %a3, -1
36  %v1 = icmp sgt i32 %v0, 1
37  br i1 %v1, label %b1, label %b8
38
39b1:                                               ; preds = %b0
40  %v2 = mul i32 %a1, 2
41  %v3 = load <16 x i32>, <16 x i32>* bitcast ([10 x i16]* @g0 to <16 x i32>*), align 128
42  %v4 = tail call <16 x i32> @llvm.hexagon.V6.vshuffh(<16 x i32> %v3) #2
43  %v5 = zext i8 %a4 to i32
44  %v6 = tail call i32 @llvm.hexagon.S2.vsplatrb(i32 %v5) #2
45  %v7 = tail call <16 x i32> @llvm.hexagon.V6.lvsplatw(i32 %v6) #2
46  %v8 = tail call <16 x i32> @llvm.hexagon.V6.vd0() #2
47  %v9 = tail call <16 x i32> @llvm.hexagon.V6.lvsplatw(i32 16843009) #2
48  %v10 = tail call <16 x i32> @llvm.hexagon.V6.lvsplatw(i32 33686018) #2
49  %v11 = icmp sgt i32 %a2, 64
50  %v12 = add i32 %a1, 64
51  %v13 = add i32 %v12, %a1
52  %v14 = icmp sgt i32 %a2, 0
53  %v15 = add i32 %a3, -2
54  %v16 = bitcast i8* %a0 to <16 x i32>*
55  %v17 = load <16 x i32>, <16 x i32>* %v16, align 64
56  br label %b2
57
58b2:                                               ; preds = %b7, %b1
59  %v18 = phi <16 x i32> [ %v17, %b1 ], [ %v28, %b7 ]
60  %v19 = phi i8* [ %a0, %b1 ], [ %v23, %b7 ]
61  %v20 = phi i8* [ %a5, %b1 ], [ %v22, %b7 ]
62  %v21 = phi i32 [ 1, %b1 ], [ %v118, %b7 ]
63  %v22 = getelementptr inbounds i8, i8* %v20, i32 %a1
64  %v23 = getelementptr inbounds i8, i8* %v19, i32 %a1
65  %v24 = bitcast i8* %v23 to <16 x i32>*
66  %v25 = getelementptr inbounds i8, i8* %v19, i32 %v2
67  %v26 = bitcast i8* %v25 to <16 x i32>*
68  %v27 = bitcast i8* %v22 to <16 x i32>*
69  %v28 = load <16 x i32>, <16 x i32>* %v24, align 64
70  %v29 = load <16 x i32>, <16 x i32>* %v26, align 64
71  br i1 %v11, label %b3, label %b4
72
73b3:                                               ; preds = %b2
74  %v30 = getelementptr inbounds i8, i8* %v19, i32 64
75  %v31 = getelementptr inbounds i8, i8* %v19, i32 %v12
76  %v32 = bitcast i8* %v31 to <16 x i32>*
77  %v33 = getelementptr inbounds i8, i8* %v19, i32 %v13
78  %v34 = bitcast i8* %v33 to <16 x i32>*
79  br label %b5
80
81b4:                                               ; preds = %b2
82  br i1 %v14, label %b5, label %b7
83
84b5:                                               ; preds = %b4, %b3
85  %v35 = phi <16 x i32>* [ %v26, %b4 ], [ %v34, %b3 ]
86  %v36 = phi <16 x i32>* [ %v24, %b4 ], [ %v32, %b3 ]
87  %v37 = phi i8* [ %v19, %b4 ], [ %v30, %b3 ]
88  %v38 = bitcast i8* %v37 to <16 x i32>*
89  br label %b6
90
91b6:                                               ; preds = %b6, %b5
92  %v39 = phi <16 x i32>* [ %v108, %b6 ], [ %v27, %b5 ]
93  %v40 = phi <16 x i32>* [ %v115, %b6 ], [ %v35, %b5 ]
94  %v41 = phi <16 x i32>* [ %v114, %b6 ], [ %v36, %b5 ]
95  %v42 = phi <16 x i32>* [ %v113, %b6 ], [ %v38, %b5 ]
96  %v43 = phi i32 [ %v116, %b6 ], [ %a2, %b5 ]
97  %v44 = phi <16 x i32> [ %v45, %b6 ], [ %v8, %b5 ]
98  %v45 = phi <16 x i32> [ %v50, %b6 ], [ %v18, %b5 ]
99  %v46 = phi <16 x i32> [ %v47, %b6 ], [ %v8, %b5 ]
100  %v47 = phi <16 x i32> [ %v51, %b6 ], [ %v28, %b5 ]
101  %v48 = phi <16 x i32> [ %v49, %b6 ], [ %v8, %b5 ]
102  %v49 = phi <16 x i32> [ %v52, %b6 ], [ %v29, %b5 ]
103  %v50 = load <16 x i32>, <16 x i32>* %v42, align 64
104  %v51 = load <16 x i32>, <16 x i32>* %v41, align 64
105  %v52 = load <16 x i32>, <16 x i32>* %v40, align 64
106  %v53 = tail call <32 x i32> @llvm.hexagon.V6.vsububh(<16 x i32> %v8, <16 x i32> %v47) #2
107  %v54 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v45, <16 x i32> %v47) #2
108  %v55 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v49, <16 x i32> %v47) #2
109  %v56 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v54, <16 x i32> %v7) #2
110  %v57 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v55, <16 x i32> %v7) #2
111  %v58 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v56, <16 x i32> %v9, <16 x i32> %v10) #2
112  %v59 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v57, <16 x i32> %v58, <16 x i32> %v9) #2
113  %v60 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v56, <16 x i32> %v8, <16 x i32> %v45) #2
114  %v61 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v57, <16 x i32> %v8, <16 x i32> %v49) #2
115  %v62 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v61, <16 x i32> %v60) #2
116  %v63 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v53, <32 x i32> %v62, i32 -1) #2
117  %v64 = tail call <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32> %v45, <16 x i32> %v44, i32 1) #2
118  %v65 = tail call <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32> %v49, <16 x i32> %v48, i32 1) #2
119  %v66 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v64, <16 x i32> %v47) #2
120  %v67 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v65, <16 x i32> %v47) #2
121  %v68 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v66, <16 x i32> %v7) #2
122  %v69 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v67, <16 x i32> %v7) #2
123  %v70 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v68, <16 x i32> %v59, <16 x i32> %v9) #2
124  %v71 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v69, <16 x i32> %v70, <16 x i32> %v9) #2
125  %v72 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v68, <16 x i32> %v8, <16 x i32> %v64) #2
126  %v73 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v69, <16 x i32> %v8, <16 x i32> %v65) #2
127  %v74 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v73, <16 x i32> %v72) #2
128  %v75 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v63, <32 x i32> %v74, i32 -1) #2
129  %v76 = tail call <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32> %v50, <16 x i32> %v45, i32 1) #2
130  %v77 = tail call <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32> %v52, <16 x i32> %v49, i32 1) #2
131  %v78 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v76, <16 x i32> %v47) #2
132  %v79 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v77, <16 x i32> %v47) #2
133  %v80 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v78, <16 x i32> %v7) #2
134  %v81 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v79, <16 x i32> %v7) #2
135  %v82 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v80, <16 x i32> %v71, <16 x i32> %v9) #2
136  %v83 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v81, <16 x i32> %v82, <16 x i32> %v9) #2
137  %v84 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v80, <16 x i32> %v8, <16 x i32> %v76) #2
138  %v85 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v81, <16 x i32> %v8, <16 x i32> %v77) #2
139  %v86 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v85, <16 x i32> %v84) #2
140  %v87 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v75, <32 x i32> %v86, i32 -1) #2
141  %v88 = tail call <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32> %v47, <16 x i32> %v46, i32 1) #2
142  %v89 = tail call <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32> %v51, <16 x i32> %v47, i32 1) #2
143  %v90 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v88, <16 x i32> %v47) #2
144  %v91 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v89, <16 x i32> %v47) #2
145  %v92 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v90, <16 x i32> %v7) #2
146  %v93 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v91, <16 x i32> %v7) #2
147  %v94 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v92, <16 x i32> %v83, <16 x i32> %v9) #2
148  %v95 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v93, <16 x i32> %v94, <16 x i32> %v9) #2
149  %v96 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v92, <16 x i32> %v8, <16 x i32> %v88) #2
150  %v97 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v93, <16 x i32> %v8, <16 x i32> %v89) #2
151  %v98 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v97, <16 x i32> %v96) #2
152  %v99 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v87, <32 x i32> %v98, i32 -1) #2
153  %v100 = tail call <32 x i32> @llvm.hexagon.V6.vlutvwh(<16 x i32> %v95, <16 x i32> %v4, i32 0) #2
154  %v101 = tail call <16 x i32> @llvm.hexagon.V6.lo(<32 x i32> %v99) #2
155  %v102 = tail call <16 x i32> @llvm.hexagon.V6.lo(<32 x i32> %v100) #2
156  %v103 = tail call <16 x i32> @llvm.hexagon.V6.vmpyhvsrs(<16 x i32> %v101, <16 x i32> %v102) #2
157  %v104 = tail call <16 x i32> @llvm.hexagon.V6.hi(<32 x i32> %v99) #2
158  %v105 = tail call <16 x i32> @llvm.hexagon.V6.hi(<32 x i32> %v100) #2
159  %v106 = tail call <16 x i32> @llvm.hexagon.V6.vmpyhvsrs(<16 x i32> %v104, <16 x i32> %v105) #2
160  %v107 = tail call <16 x i32> @llvm.hexagon.V6.vsathub(<16 x i32> %v106, <16 x i32> %v103) #2
161  %v108 = getelementptr inbounds <16 x i32>, <16 x i32>* %v39, i32 1
162  store <16 x i32> %v107, <16 x i32>* %v39, align 64
163  %v109 = icmp sgt i32 %v43, 128
164  %v110 = getelementptr inbounds <16 x i32>, <16 x i32>* %v42, i32 1
165  %v111 = getelementptr inbounds <16 x i32>, <16 x i32>* %v41, i32 1
166  %v112 = getelementptr inbounds <16 x i32>, <16 x i32>* %v40, i32 1
167  %v113 = select i1 %v109, <16 x i32>* %v110, <16 x i32>* %v42
168  %v114 = select i1 %v109, <16 x i32>* %v111, <16 x i32>* %v41
169  %v115 = select i1 %v109, <16 x i32>* %v112, <16 x i32>* %v40
170  %v116 = add nsw i32 %v43, -64
171  %v117 = icmp sgt i32 %v43, 64
172  br i1 %v117, label %b6, label %b7
173
174b7:                                               ; preds = %b6, %b4
175  %v118 = add nuw nsw i32 %v21, 1
176  %v119 = icmp eq i32 %v21, %v15
177  br i1 %v119, label %b8, label %b2
178
179b8:                                               ; preds = %b7, %b0
180  ret void
181}
182
183attributes #0 = { nounwind readnone }
184attributes #1 = { nounwind "target-cpu"="hexagonv62" "target-features"="+hvx,+hvx-length64b" }
185attributes #2 = { nounwind }
186