1 ; RUN: llc -march=hexagon -O2 < %s -pipeliner-experimental-cg=true -verify-machineinstrs | FileCheck %s
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.
7 ; CHECK: loop0(.LBB0_[[LOOP:.]],
8 ; CHECK: .LBB0_[[LOOP]]:
10 ; CHECK: }{{[ \t]*}}:endloop
12 @g0 = external constant [10 x i16], align 128
14 declare i32 @llvm.hexagon.S2.vsplatrb(i32) #0
15 declare <16 x i32> @llvm.hexagon.V6.vshuffh(<16 x i32>) #0
16 declare <16 x i32> @llvm.hexagon.V6.lvsplatw(i32) #0
17 declare <16 x i32> @llvm.hexagon.V6.vd0() #0
18 declare <32 x i32> @llvm.hexagon.V6.vsububh(<16 x i32>, <16 x i32>) #0
19 declare <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32>, <16 x i32>) #0
20 declare <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32>, <16 x i32>) #0
21 declare <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1>, <16 x i32>, <16 x i32>) #0
22 declare <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1>, <16 x i32>, <16 x i32>) #0
23 declare <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32>, <16 x i32>) #0
24 declare <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32>, <32 x i32>, i32) #0
25 declare <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32>, <16 x i32>, i32) #0
26 declare <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32>, <16 x i32>, i32) #0
27 declare <32 x i32> @llvm.hexagon.V6.vlutvwh(<16 x i32>, <16 x i32>, i32) #0
28 declare <16 x i32> @llvm.hexagon.V6.vmpyhvsrs(<16 x i32>, <16 x i32>) #0
29 declare <16 x i32> @llvm.hexagon.V6.lo(<32 x i32>) #0
30 declare <16 x i32> @llvm.hexagon.V6.hi(<32 x i32>) #0
31 declare <16 x i32> @llvm.hexagon.V6.vsathub(<16 x i32>, <16 x i32>) #0
33 define void @f0(ptr nocapture readonly %a0, i32 %a1, i32 %a2, i32 %a3, i8 zeroext %a4, ptr nocapture %a5) #1 {
35 %v0 = add nsw i32 %a3, -1
36 %v1 = icmp sgt i32 %v0, 1
37 br i1 %v1, label %b1, label %b8
41 %v3 = load <16 x i32>, ptr @g0, 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 %v17 = load <16 x i32>, ptr %a0, align 64
57 b2: ; preds = %b7, %b1
58 %v18 = phi <16 x i32> [ %v17, %b1 ], [ %v28, %b7 ]
59 %v19 = phi ptr [ %a0, %b1 ], [ %v23, %b7 ]
60 %v20 = phi ptr [ %a5, %b1 ], [ %v22, %b7 ]
61 %v21 = phi i32 [ 1, %b1 ], [ %v118, %b7 ]
62 %v22 = getelementptr inbounds i8, ptr %v20, i32 %a1
63 %v23 = getelementptr inbounds i8, ptr %v19, i32 %a1
64 %v25 = getelementptr inbounds i8, ptr %v19, i32 %v2
65 %v28 = load <16 x i32>, ptr %v23, align 64
66 %v29 = load <16 x i32>, ptr %v25, align 64
67 br i1 %v11, label %b3, label %b4
70 %v30 = getelementptr inbounds i8, ptr %v19, i32 64
71 %v31 = getelementptr inbounds i8, ptr %v19, i32 %v12
72 %v33 = getelementptr inbounds i8, ptr %v19, i32 %v13
76 br i1 %v14, label %b5, label %b7
78 b5: ; preds = %b4, %b3
79 %v35 = phi ptr [ %v25, %b4 ], [ %v33, %b3 ]
80 %v36 = phi ptr [ %v23, %b4 ], [ %v31, %b3 ]
81 %v37 = phi ptr [ %v19, %b4 ], [ %v30, %b3 ]
84 b6: ; preds = %b6, %b5
85 %v39 = phi ptr [ %v108, %b6 ], [ %v22, %b5 ]
86 %v40 = phi ptr [ %v115, %b6 ], [ %v35, %b5 ]
87 %v41 = phi ptr [ %v114, %b6 ], [ %v36, %b5 ]
88 %v42 = phi ptr [ %v113, %b6 ], [ %v37, %b5 ]
89 %v43 = phi i32 [ %v116, %b6 ], [ %a2, %b5 ]
90 %v44 = phi <16 x i32> [ %v45, %b6 ], [ %v8, %b5 ]
91 %v45 = phi <16 x i32> [ %v50, %b6 ], [ %v18, %b5 ]
92 %v46 = phi <16 x i32> [ %v47, %b6 ], [ %v8, %b5 ]
93 %v47 = phi <16 x i32> [ %v51, %b6 ], [ %v28, %b5 ]
94 %v48 = phi <16 x i32> [ %v49, %b6 ], [ %v8, %b5 ]
95 %v49 = phi <16 x i32> [ %v52, %b6 ], [ %v29, %b5 ]
96 %v50 = load <16 x i32>, ptr %v42, align 64
97 %v51 = load <16 x i32>, ptr %v41, align 64
98 %v52 = load <16 x i32>, ptr %v40, align 64
99 %v53 = tail call <32 x i32> @llvm.hexagon.V6.vsububh(<16 x i32> %v8, <16 x i32> %v47) #2
100 %v54 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v45, <16 x i32> %v47) #2
101 %v55 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v49, <16 x i32> %v47) #2
102 %v56 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v54, <16 x i32> %v7) #2
103 %v57 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v55, <16 x i32> %v7) #2
104 %v58 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v56, <16 x i32> %v9, <16 x i32> %v10) #2
105 %v59 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v57, <16 x i32> %v58, <16 x i32> %v9) #2
106 %v60 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v56, <16 x i32> %v8, <16 x i32> %v45) #2
107 %v61 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v57, <16 x i32> %v8, <16 x i32> %v49) #2
108 %v62 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v61, <16 x i32> %v60) #2
109 %v63 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v53, <32 x i32> %v62, i32 -1) #2
110 %v64 = tail call <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32> %v45, <16 x i32> %v44, i32 1) #2
111 %v65 = tail call <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32> %v49, <16 x i32> %v48, i32 1) #2
112 %v66 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v64, <16 x i32> %v47) #2
113 %v67 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v65, <16 x i32> %v47) #2
114 %v68 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v66, <16 x i32> %v7) #2
115 %v69 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v67, <16 x i32> %v7) #2
116 %v70 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v68, <16 x i32> %v59, <16 x i32> %v9) #2
117 %v71 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v69, <16 x i32> %v70, <16 x i32> %v9) #2
118 %v72 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v68, <16 x i32> %v8, <16 x i32> %v64) #2
119 %v73 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v69, <16 x i32> %v8, <16 x i32> %v65) #2
120 %v74 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v73, <16 x i32> %v72) #2
121 %v75 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v63, <32 x i32> %v74, i32 -1) #2
122 %v76 = tail call <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32> %v50, <16 x i32> %v45, i32 1) #2
123 %v77 = tail call <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32> %v52, <16 x i32> %v49, i32 1) #2
124 %v78 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v76, <16 x i32> %v47) #2
125 %v79 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v77, <16 x i32> %v47) #2
126 %v80 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v78, <16 x i32> %v7) #2
127 %v81 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v79, <16 x i32> %v7) #2
128 %v82 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v80, <16 x i32> %v71, <16 x i32> %v9) #2
129 %v83 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v81, <16 x i32> %v82, <16 x i32> %v9) #2
130 %v84 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v80, <16 x i32> %v8, <16 x i32> %v76) #2
131 %v85 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v81, <16 x i32> %v8, <16 x i32> %v77) #2
132 %v86 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v85, <16 x i32> %v84) #2
133 %v87 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v75, <32 x i32> %v86, i32 -1) #2
134 %v88 = tail call <16 x i32> @llvm.hexagon.V6.vlalignbi(<16 x i32> %v47, <16 x i32> %v46, i32 1) #2
135 %v89 = tail call <16 x i32> @llvm.hexagon.V6.valignbi(<16 x i32> %v51, <16 x i32> %v47, i32 1) #2
136 %v90 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v88, <16 x i32> %v47) #2
137 %v91 = tail call <16 x i32> @llvm.hexagon.V6.vabsdiffub(<16 x i32> %v89, <16 x i32> %v47) #2
138 %v92 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v90, <16 x i32> %v7) #2
139 %v93 = tail call <64 x i1> @llvm.hexagon.V6.vgtub(<16 x i32> %v91, <16 x i32> %v7) #2
140 %v94 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v92, <16 x i32> %v83, <16 x i32> %v9) #2
141 %v95 = tail call <16 x i32> @llvm.hexagon.V6.vaddbnq(<64 x i1> %v93, <16 x i32> %v94, <16 x i32> %v9) #2
142 %v96 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v92, <16 x i32> %v8, <16 x i32> %v88) #2
143 %v97 = tail call <16 x i32> @llvm.hexagon.V6.vmux(<64 x i1> %v93, <16 x i32> %v8, <16 x i32> %v89) #2
144 %v98 = tail call <32 x i32> @llvm.hexagon.V6.vcombine(<16 x i32> %v97, <16 x i32> %v96) #2
145 %v99 = tail call <32 x i32> @llvm.hexagon.V6.vmpabus.acc(<32 x i32> %v87, <32 x i32> %v98, i32 -1) #2
146 %v100 = tail call <32 x i32> @llvm.hexagon.V6.vlutvwh(<16 x i32> %v95, <16 x i32> %v4, i32 0) #2
147 %v101 = tail call <16 x i32> @llvm.hexagon.V6.lo(<32 x i32> %v99) #2
148 %v102 = tail call <16 x i32> @llvm.hexagon.V6.lo(<32 x i32> %v100) #2
149 %v103 = tail call <16 x i32> @llvm.hexagon.V6.vmpyhvsrs(<16 x i32> %v101, <16 x i32> %v102) #2
150 %v104 = tail call <16 x i32> @llvm.hexagon.V6.hi(<32 x i32> %v99) #2
151 %v105 = tail call <16 x i32> @llvm.hexagon.V6.hi(<32 x i32> %v100) #2
152 %v106 = tail call <16 x i32> @llvm.hexagon.V6.vmpyhvsrs(<16 x i32> %v104, <16 x i32> %v105) #2
153 %v107 = tail call <16 x i32> @llvm.hexagon.V6.vsathub(<16 x i32> %v106, <16 x i32> %v103) #2
154 %v108 = getelementptr inbounds <16 x i32>, ptr %v39, i32 1
155 store <16 x i32> %v107, ptr %v39, align 64
156 %v109 = icmp sgt i32 %v43, 128
157 %v110 = getelementptr inbounds <16 x i32>, ptr %v42, i32 1
158 %v111 = getelementptr inbounds <16 x i32>, ptr %v41, i32 1
159 %v112 = getelementptr inbounds <16 x i32>, ptr %v40, i32 1
160 %v113 = select i1 %v109, ptr %v110, ptr %v42
161 %v114 = select i1 %v109, ptr %v111, ptr %v41
162 %v115 = select i1 %v109, ptr %v112, ptr %v40
163 %v116 = add nsw i32 %v43, -64
164 %v117 = icmp sgt i32 %v43, 64
165 br i1 %v117, label %b6, label %b7
167 b7: ; preds = %b6, %b4
168 %v118 = add nuw nsw i32 %v21, 1
169 %v119 = icmp eq i32 %v21, %v15
170 br i1 %v119, label %b8, label %b2
172 b8: ; preds = %b7, %b0
176 attributes #0 = { nounwind readnone }
177 attributes #1 = { nounwind "target-cpu"="hexagonv62" "target-features"="+hvx,+hvx-length64b" }
178 attributes #2 = { nounwind }