]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/Hexagon/swp-const-tc3.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / CodeGen / Hexagon / swp-const-tc3.ll
1 ; RUN: llc -march=hexagon < %s | FileCheck %s
2
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.
7
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]+}})
12
13 ; Function Attrs: nounwind readonly
14 define signext i16 @f0(i16* nocapture readonly %a0, i16* nocapture readnone %a1, i16* nocapture readonly %a2, i16* nocapture readonly %a3, i16 signext %a4, i16 signext %a5, i16 signext %a6) #0 {
15 b0:
16   %v0 = icmp sgt i16 %a5, 0
17   br i1 %v0, label %b1, label %b7
18
19 b1:                                               ; preds = %b0
20   %v1 = load i16, i16* %a0, align 2
21   %v2 = sext i16 %v1 to i32
22   %v3 = load i16, i16* %a3, align 2
23   %v4 = sext i16 %v3 to i32
24   br label %b2
25
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 i16* [ %a2, %b1 ], [ %v38, %b6 ]
31   %v9 = load i16, i16* %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, i16* %v8, i32 1
40   br label %b3
41
42 b3:                                               ; preds = %b3, %b2
43   %v18 = phi i16* [ %v8, %b2 ], [ %v19, %b3 ]
44   %v19 = phi i16* [ %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, i16* %a0, i32 %v21
48   %v23 = load i16, i16* %v22, align 2
49   %v24 = sext i16 %v23 to i32
50   %v25 = load i16, i16* %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, i16* %a3, i32 %v21
56   %v31 = load i16, i16* %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, i16* %v18, i32 2
64   %v39 = icmp eq i32 %v37, 3
65   br i1 %v39, label %b4, label %b3
66
67 b4:                                               ; preds = %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
71
72 b5:                                               ; preds = %b4
73   %v42 = tail call i32 @llvm.hexagon.A2.addsat(i32 %v36, i32 0)
74   br label %b6
75
76 b6:                                               ; preds = %b5, %b4
77   %v43 = phi i16 [ %v6, %b5 ], [ %v7, %b4 ]
78   %v44 = phi i32 [ %v42, %b5 ], [ %v5, %b4 ]
79   %v45 = add i16 %v6, 1
80   %v46 = icmp eq i16 %v45, %a5
81   br i1 %v46, label %b7, label %b2
82
83 b7:                                               ; preds = %b6, %b0
84   %v47 = phi i16 [ 0, %b0 ], [ %v43, %b6 ]
85   ret i16 %v47
86 }
87
88 ; Function Attrs: nounwind readnone
89 declare i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32, i32) #1
90
91 ; Function Attrs: nounwind readnone
92 declare i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32, i32) #1
93
94 ; Function Attrs: nounwind readnone
95 declare i32 @llvm.hexagon.M2.hmmpyl.s1(i32, i32) #1
96
97 ; Function Attrs: nounwind readnone
98 declare i32 @llvm.hexagon.S2.asr.r.r.sat(i32, i32) #1
99
100 ; Function Attrs: nounwind readnone
101 declare i32 @llvm.hexagon.A2.addsat(i32, i32) #1
102
103 ; Function Attrs: nounwind readnone
104 declare i32 @llvm.hexagon.A2.subsat(i32, i32) #1
105
106 attributes #0 = { nounwind readonly "target-cpu"="hexagonv60" }
107 attributes #1 = { nounwind readnone }