1; RUN: llc -march=hexagon -O2 < %s
2; REQUIRES: asserts
3
4target triple = "hexagon-unknown--elf"
5
6@g0 = global i32 0, align 4
7@g1 = global i32 0, align 4
8@g2 = global i32 0, align 4
9@g3 = global i32 0, align 4
10@g4 = common global [100 x i32] zeroinitializer, align 8
11@g5 = common global [100 x i32] zeroinitializer, align 8
12@g6 = private unnamed_addr constant [13 x i8] c"ping started\00"
13@g7 = private unnamed_addr constant [13 x i8] c"pong started\00"
14
15; Function Attrs: nounwind
16define void @f0(i8* nocapture readnone %a0) #0 {
17b0:
18  tail call void @f1(i8* %a0, i32 0)
19  ret void
20}
21
22; Function Attrs: nounwind
23define internal void @f1(i8* nocapture readnone %a0, i32 %a1) #0 {
24b0:
25  %v0 = icmp eq i32 %a1, 1
26  br i1 %v0, label %b2, label %b1
27
28b1:                                               ; preds = %b0
29  %v1 = tail call i32 @f3(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @g6, i32 0, i32 0))
30  store volatile i32 1, i32* @g0, align 4, !tbaa !0
31  br label %b3
32
33b2:                                               ; preds = %b0
34  %v2 = tail call i32 @f3(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @g7, i32 0, i32 0))
35  store volatile i32 1, i32* @g1, align 4, !tbaa !0
36  br label %b3
37
38b3:                                               ; preds = %b3, %b2, %b1
39  %v3 = load volatile i32, i32* @g2, align 4, !tbaa !0
40  %v4 = icmp eq i32 %v3, 0
41  br i1 %v4, label %b3, label %b4
42
43b4:                                               ; preds = %b3
44  %v5 = select i1 %v0, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @g5, i32 0, i32 0), i32* getelementptr inbounds ([100 x i32], [100 x i32]* @g4, i32 0, i32 0)
45  br label %b5
46
47b5:                                               ; preds = %b5, %b4
48  %v6 = phi i32* [ %v5, %b4 ], [ %v29, %b5 ]
49  %v7 = phi i32 [ 0, %b4 ], [ %v27, %b5 ]
50  %v8 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
51  store i32 %v8, i32* %v6, align 4, !tbaa !0
52  %v9 = getelementptr i32, i32* %v6, i32 1
53  %v10 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
54  store i32 %v10, i32* %v9, align 4, !tbaa !0
55  %v11 = getelementptr i32, i32* %v6, i32 2
56  %v12 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
57  store i32 %v12, i32* %v11, align 4, !tbaa !0
58  %v13 = getelementptr i32, i32* %v6, i32 3
59  %v14 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
60  store i32 %v14, i32* %v13, align 4, !tbaa !0
61  %v15 = getelementptr i32, i32* %v6, i32 4
62  %v16 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
63  store i32 %v16, i32* %v15, align 4, !tbaa !0
64  %v17 = getelementptr i32, i32* %v6, i32 5
65  %v18 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
66  store i32 %v18, i32* %v17, align 4, !tbaa !0
67  %v19 = getelementptr i32, i32* %v6, i32 6
68  %v20 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
69  store i32 %v20, i32* %v19, align 4, !tbaa !0
70  %v21 = getelementptr i32, i32* %v6, i32 7
71  %v22 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
72  store i32 %v22, i32* %v21, align 4, !tbaa !0
73  %v23 = getelementptr i32, i32* %v6, i32 8
74  %v24 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
75  store i32 %v24, i32* %v23, align 4, !tbaa !0
76  %v25 = getelementptr i32, i32* %v6, i32 9
77  %v26 = tail call i32 asm sideeffect "1:     $0 = memw_locked($2)\0A       $0 = add($0, $3)\0A       memw_locked($2, p0) = $0\0A       if !p0 jump 1b\0A", "=&r,=*m,r,r,*m,~{p0}"(i32* @g3, i32* @g3, i32 1, i32* @g3), !srcloc !4
78  store i32 %v26, i32* %v25, align 4, !tbaa !0
79  %v27 = add nsw i32 %v7, 10
80  %v28 = icmp eq i32 %v27, 100
81  %v29 = getelementptr i32, i32* %v6, i32 10
82  br i1 %v28, label %b6, label %b5
83
84b6:                                               ; preds = %b5
85  tail call void @f2(i32 0) #1
86  ret void
87}
88
89; Function Attrs: nounwind
90declare void @f2(i32) #1
91
92; Function Attrs: nounwind
93declare i32 @f3(i8* nocapture readonly) #1
94
95attributes #0 = { nounwind "target-cpu"="hexagonv60" "target-fatures"="+hvx,+hvx-length64b" }
96attributes #1 = { nounwind }
97
98!0 = !{!1, !1, i64 0}
99!1 = !{!"int", !2, i64 0}
100!2 = !{!"omnipotent char", !3, i64 0}
101!3 = !{!"Simple C/C++ TBAA"}
102!4 = !{i32 12730, i32 12771, i32 12807, i32 12851}
103