1 ; RUN: llc -march=hexagon < %s -pipeliner-experimental-cg=true | FileCheck %s
3 ; Test that the pipeliner correctly fixes up the pipelined CFG when the loop
4 ; has a constant trip count, and the trip count is less than the number of
5 ; prolog blocks. Prior to the bug, the pipeliner deleted one extra prolog and
6 ; epilog stage. We check this by counting the number of sxth instructions.
8 ; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
9 ; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
10 ; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
11 ; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
13 ; Function Attrs: nounwind readonly
14 define signext i16 @f0(ptr nocapture readonly %a0, ptr nocapture readnone %a1, ptr nocapture readonly %a2, ptr nocapture readonly %a3, i16 signext %a4, i16 signext %a5, i16 signext %a6) #0 {
16 %v0 = icmp sgt i16 %a5, 0
17 br i1 %v0, label %b1, label %b7
20 %v1 = load i16, ptr %a0, align 2
21 %v2 = sext i16 %v1 to i32
22 %v3 = load i16, ptr %a3, align 2
23 %v4 = sext i16 %v3 to i32
26 b2: ; preds = %b6, %b1
27 %v5 = phi i32 [ 2147483647, %b1 ], [ %v44, %b6 ]
28 %v6 = phi i16 [ 0, %b1 ], [ %v45, %b6 ]
29 %v7 = phi i16 [ 0, %b1 ], [ %v43, %b6 ]
30 %v8 = phi ptr [ %a2, %b1 ], [ %v38, %b6 ]
31 %v9 = load i16, ptr %v8, align 2
32 %v10 = sext i16 %v9 to i32
33 %v11 = tail call i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32 %v2, i32 %v10)
34 %v12 = shl i32 %v11, 16
35 %v13 = ashr exact i32 %v12, 16
36 %v14 = tail call i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32 %v13, i32 %v4)
37 %v15 = tail call i32 @llvm.hexagon.M2.hmmpyl.s1(i32 %v14, i32 %v13)
38 %v16 = tail call i32 @llvm.hexagon.S2.asr.r.r.sat(i32 %v15, i32 10)
39 %v17 = getelementptr inbounds i16, ptr %v8, i32 1
42 b3: ; preds = %b3, %b2
43 %v18 = phi ptr [ %v8, %b2 ], [ %v19, %b3 ]
44 %v19 = phi ptr [ %v17, %b2 ], [ %v38, %b3 ]
45 %v20 = phi i32 [ %v16, %b2 ], [ %v36, %b3 ]
46 %v21 = phi i32 [ 1, %b2 ], [ %v37, %b3 ]
47 %v22 = getelementptr inbounds i16, ptr %a0, i32 %v21
48 %v23 = load i16, ptr %v22, align 2
49 %v24 = sext i16 %v23 to i32
50 %v25 = load i16, ptr %v19, align 2
51 %v26 = sext i16 %v25 to i32
52 %v27 = tail call i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32 %v24, i32 %v26)
53 %v28 = shl i32 %v27, 16
54 %v29 = ashr exact i32 %v28, 16
55 %v30 = getelementptr inbounds i16, ptr %a3, i32 %v21
56 %v31 = load i16, ptr %v30, align 2
57 %v32 = sext i16 %v31 to i32
58 %v33 = tail call i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32 %v29, i32 %v32)
59 %v34 = tail call i32 @llvm.hexagon.M2.hmmpyl.s1(i32 %v33, i32 %v29)
60 %v35 = tail call i32 @llvm.hexagon.S2.asr.r.r.sat(i32 %v34, i32 10)
61 %v36 = tail call i32 @llvm.hexagon.A2.addsat(i32 %v20, i32 %v35)
62 %v37 = add i32 %v21, 1
63 %v38 = getelementptr inbounds i16, ptr %v18, i32 2
64 %v39 = icmp eq i32 %v37, 3
65 br i1 %v39, label %b4, label %b3
68 %v40 = tail call i32 @llvm.hexagon.A2.subsat(i32 %v36, i32 %v5)
69 %v41 = icmp slt i32 %v40, 0
70 br i1 %v41, label %b5, label %b6
73 %v42 = tail call i32 @llvm.hexagon.A2.addsat(i32 %v36, i32 0)
76 b6: ; preds = %b5, %b4
77 %v43 = phi i16 [ %v6, %b5 ], [ %v7, %b4 ]
78 %v44 = phi i32 [ %v42, %b5 ], [ %v5, %b4 ]
80 %v46 = icmp eq i16 %v45, %a5
81 br i1 %v46, label %b7, label %b2
83 b7: ; preds = %b6, %b0
84 %v47 = phi i16 [ 0, %b0 ], [ %v43, %b6 ]
88 ; Function Attrs: nounwind readnone
89 declare i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32, i32) #1
91 ; Function Attrs: nounwind readnone
92 declare i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32, i32) #1
94 ; Function Attrs: nounwind readnone
95 declare i32 @llvm.hexagon.M2.hmmpyl.s1(i32, i32) #1
97 ; Function Attrs: nounwind readnone
98 declare i32 @llvm.hexagon.S2.asr.r.r.sat(i32, i32) #1
100 ; Function Attrs: nounwind readnone
101 declare i32 @llvm.hexagon.A2.addsat(i32, i32) #1
103 ; Function Attrs: nounwind readnone
104 declare i32 @llvm.hexagon.A2.subsat(i32, i32) #1
106 attributes #0 = { nounwind readonly "target-cpu"="hexagonv60" }
107 attributes #1 = { nounwind readnone }