xref: /llvm-project/llvm/test/CodeGen/Hexagon/loop-balign.ll (revision 2208c97c1bec2512d4e47b6223db6d95a7037956)
1; RUN: llc -mtriple=hexagon -O3 < %s | FileCheck %s -check-prefix=BALIGN
2; BALIGN: .p2align{{.*}}5
3
4; The test for checking the alignment of 'for.body4.for.body4_crit_edge' basic block
5
6define dso_local void @foo(i32 %nCol, i32 %nRow, ptr nocapture %resMat) local_unnamed_addr {
7entry:
8  %shl = shl i32 %nRow, 2
9  %cmp36 = icmp sgt i32 %nRow, 0
10  %0 = add i32 %nCol, -1
11  %.inv = icmp slt i32 %0, 1
12  %1 = select i1 %.inv, i32 1, i32 %nCol
13  br label %Outerloop
14
15Outerloop:                                        ; preds = %for.end7, %entry
16  %r12.0 = phi i32 [ 0, %entry ], [ %inc8, %for.end7 ]
17  %r7_6.0 = phi i64 [ undef, %entry ], [ %r7_6.1.lcssa, %for.end7 ]
18  %r0i.0 = phi i32 [ undef, %entry ], [ %r0i.1.lcssa, %for.end7 ]
19  %r5.0 = phi ptr [ %resMat, %entry ], [ %r5.1.lcssa, %for.end7 ]
20  %r8.0 = phi i32 [ %shl, %entry ], [ %r8.1.lcssa, %for.end7 ]
21  br i1 %cmp36, label %for.body.lr.ph, label %for.end7
22
23for.body.lr.ph:                                   ; preds = %Outerloop
24  %cmp332 = icmp eq i32 %r12.0, 0
25  %exitcond.peel = icmp eq i32 %r12.0, 1
26  br label %for.body
27
28for.body:                                         ; preds = %for.end, %for.body.lr.ph
29  %r8.141 = phi i32 [ %r8.0, %for.body.lr.ph ], [ %add, %for.end ]
30  %r5.140 = phi ptr [ %r5.0, %for.body.lr.ph ], [ %add.ptr, %for.end ]
31  %i.039 = phi i32 [ 0, %for.body.lr.ph ], [ %inc6, %for.end ]
32  %r0i.138 = phi i32 [ %r0i.0, %for.body.lr.ph ], [ %4, %for.end ]
33  %r7_6.137 = phi i64 [ %r7_6.0, %for.body.lr.ph ], [ %r7_6.2.lcssa, %for.end ]
34  %add = add nsw i32 %r8.141, %shl
35  br i1 %cmp332, label %for.end, label %for.body4.peel
36
37for.body4.peel:                                   ; preds = %for.body
38  %r1i.0.in.peel = inttoptr i32 %r8.141 to ptr
39  %r1i.0.peel = load i32, ptr %r1i.0.in.peel, align 4
40  %2 = tail call i64 @llvm.hexagon.M2.dpmpyss.nac.s0(i64 %r7_6.137, i32 %r1i.0.peel, i32 %r0i.138)
41  br i1 %exitcond.peel, label %for.end, label %for.body4.preheader.peel.newph
42
43for.body4.preheader.peel.newph:                   ; preds = %for.body4.peel
44  %r1i.0.in = inttoptr i32 %add to ptr
45  %r1i.0 = load i32, ptr %r1i.0.in, align 4
46  br label %for.body4
47
48for.body4:                                        ; preds = %for.body4.for.body4_crit_edge, %for.body4.preheader.peel.newph
49  %inc.phi = phi i32 [ %inc.0, %for.body4.for.body4_crit_edge ], [ 2, %for.body4.preheader.peel.newph ]
50  %r7_6.233 = phi i64 [ %3, %for.body4.for.body4_crit_edge ], [ %2, %for.body4.preheader.peel.newph ]
51  %3 = tail call i64 @llvm.hexagon.M2.dpmpyss.nac.s0(i64 %r7_6.233, i32 %r1i.0, i32 %r0i.138)
52  %exitcond = icmp eq i32 %inc.phi, %r12.0
53  br i1 %exitcond, label %for.end.loopexit, label %for.body4.for.body4_crit_edge
54
55for.body4.for.body4_crit_edge:                    ; preds = %for.body4
56  %inc.0 = add nuw nsw i32 %inc.phi, 1
57  br label %for.body4
58
59for.end.loopexit:                                 ; preds = %for.body4
60  br label %for.end
61
62for.end:                                          ; preds = %for.end.loopexit, %for.body4.peel, %for.body
63  %r7_6.2.lcssa = phi i64 [ %r7_6.137, %for.body ], [ %2, %for.body4.peel ], [ %3, %for.end.loopexit ]
64  %4 = tail call i32 @llvm.hexagon.S2.clbp(i64 %r7_6.2.lcssa)
65  store i32 %4, ptr %r5.140, align 4
66  %add.ptr = getelementptr inbounds i8, ptr %r5.140, i32 undef
67  %inc6 = add nuw nsw i32 %i.039, 1
68  %exitcond47 = icmp eq i32 %inc6, %nRow
69  br i1 %exitcond47, label %for.end7.loopexit, label %for.body
70
71for.end7.loopexit:                                ; preds = %for.end
72  br label %for.end7
73
74for.end7:                                         ; preds = %for.end7.loopexit, %Outerloop
75  %r7_6.1.lcssa = phi i64 [ %r7_6.0, %Outerloop ], [ %r7_6.2.lcssa, %for.end7.loopexit ]
76  %r0i.1.lcssa = phi i32 [ %r0i.0, %Outerloop ], [ %4, %for.end7.loopexit ]
77  %r5.1.lcssa = phi ptr [ %r5.0, %Outerloop ], [ %add.ptr, %for.end7.loopexit ]
78  %r8.1.lcssa = phi i32 [ %r8.0, %Outerloop ], [ %add, %for.end7.loopexit ]
79  %inc8 = add nuw i32 %r12.0, 1
80  %exitcond48 = icmp eq i32 %inc8, %1
81  br i1 %exitcond48, label %if.end, label %Outerloop
82
83if.end:                                           ; preds = %for.end7
84  ret void
85}
86
87; Function Attrs: nounwind readnone
88declare i64 @llvm.hexagon.M2.dpmpyss.nac.s0(i64, i32, i32)
89
90; Function Attrs: nounwind readnone
91declare i32 @llvm.hexagon.S2.clbp(i64)
92