1 ; RUN: llc -march=hexagon < %s | FileCheck %s
2 ; Make sure that the loop in the end has only one basic block.
6 ; Rely on the comments, make sure the one for the loop header is present.
11 target triple = "hexagon"
13 define i32 @fred(i32 %a0, i64* nocapture readonly %a1) #0 {
15 %v3 = bitcast i64* %a1 to i32*
16 %v4 = getelementptr inbounds i32, i32* %v3, i32 1
17 %v5 = zext i32 %a0 to i64
20 loop: ; preds = %should_merge, %b2
21 %v7 = phi i32 [ 0, %b2 ], [ %v49, %should_merge ]
22 %v8 = phi i32 [ 0, %b2 ], [ %v42, %should_merge ]
23 %v9 = phi i32* [ %v4, %b2 ], [ %v53, %should_merge ]
24 %v10 = phi i32 [ 0, %b2 ], [ %v30, %should_merge ]
25 %v11 = phi i32* [ %v3, %b2 ], [ %v51, %should_merge ]
26 %v12 = phi i32 [ 0, %b2 ], [ %v23, %should_merge ]
27 %v13 = phi i32 [ 2, %b2 ], [ %v54, %should_merge ]
28 %v14 = load i32, i32* %v11, align 4, !tbaa !0
29 %v15 = load i32, i32* %v9, align 4, !tbaa !0
30 %v16 = icmp ult i32 %v13, 30
31 %v17 = zext i32 %v12 to i64
32 %v18 = shl nuw i64 %v17, 32
33 %v19 = zext i32 %v14 to i64
34 %v20 = or i64 %v18, %v19
35 %v21 = tail call i64 @llvm.hexagon.A2.addp(i64 %v20, i64 %v5)
36 %v22 = lshr i64 %v21, 32
37 %v23 = trunc i64 %v22 to i32
38 %v24 = zext i32 %v10 to i64
39 %v25 = shl nuw i64 %v24, 32
40 %v26 = zext i32 %v15 to i64
41 %v27 = or i64 %v25, %v26
42 %v28 = tail call i64 @llvm.hexagon.A2.addp(i64 %v27, i64 %v5)
43 %v29 = lshr i64 %v28, 32
44 %v30 = trunc i64 %v29 to i32
45 %v31 = getelementptr inbounds i32, i32* %v3, i32 %v13
46 %v32 = load i32, i32* %v31, align 4, !tbaa !0
48 %v34 = getelementptr inbounds i32, i32* %v3, i32 %v33
49 %v35 = load i32, i32* %v34, align 4, !tbaa !0
50 %v36 = zext i32 %v8 to i64
51 %v37 = shl nuw i64 %v36, 32
52 %v38 = zext i32 %v32 to i64
53 %v39 = or i64 %v37, %v38
54 %v40 = tail call i64 @llvm.hexagon.A2.subp(i64 %v39, i64 %v5)
55 %v41 = lshr i64 %v40, 32
56 %v42 = trunc i64 %v41 to i32
57 %v43 = zext i32 %v7 to i64
58 %v44 = shl nuw i64 %v43, 32
59 %v45 = zext i32 %v35 to i64
60 %v46 = or i64 %v44, %v45
61 %v47 = tail call i64 @llvm.hexagon.A2.subp(i64 %v46, i64 %v5)
62 %v48 = lshr i64 %v47, 32
63 %v49 = trunc i64 %v48 to i32
64 br i1 %v16, label %should_merge, label %exit
66 should_merge: ; preds = %loop
67 %v50 = add nuw nsw i32 %v13, 2
68 %v51 = getelementptr inbounds i32, i32* %v3, i32 %v50
69 %v52 = add nuw nsw i32 %v13, 3
70 %v53 = getelementptr inbounds i32, i32* %v3, i32 %v52
71 %v54 = add nuw nsw i32 %v13, 4
75 %v57 = tail call i64 @llvm.hexagon.A2.combinew(i32 %v42, i32 %v23)
76 %v58 = tail call i64 @llvm.hexagon.A2.combinew(i32 %v49, i32 %v30)
77 %v59 = tail call i64 @llvm.hexagon.A2.addp(i64 %v57, i64 %v58)
78 %v60 = lshr i64 %v59, 32
79 %v61 = trunc i64 %v60 to i32
83 declare i64 @llvm.hexagon.A2.addp(i64, i64) #1
84 declare i64 @llvm.hexagon.A2.subp(i64, i64) #1
85 declare i64 @llvm.hexagon.A2.combinew(i32, i32) #1
87 attributes #0 = { nounwind readonly "target-cpu"="hexagonv60" "target-features"="-hvx,-long-calls" }
88 attributes #1 = { nounwind readnone }
91 !1 = !{!"long", !2, i64 0}
92 !2 = !{!"omnipotent char", !3, i64 0}
93 !3 = !{!"Simple C/C++ TBAA"}