xref: /llvm-project/llvm/test/Transforms/LoopUnrollAndJam/pragma-disable-unroll.ll (revision 865d88d47f29103c61cd1f7048707d5d02a0a985)
1; RUN: opt -passes=loop-unroll -debug-only=loop-unroll -S < %s  2>&1 | FileCheck %s
2; REQUIRES: asserts
3
4
5; CHECK: Loop Unroll: F[test]
6; CHECK-NEXT: Not unrolling loop since parent loop has llvm.loop.unroll_and_jam
7; CHECK: Loop Unroll: F[test]
8; CHECK-NEXT: Not unrolling loop since it has llvm.loop.unroll_and_jam
9
10define i32 @test() {
11for.body4.preheader.preheader:
12  br label %for.body4.preheader4
13
14for.body4.preheader4:                             ; preds = %for.cond.cleanup3, %for.body4.preheader.preheader
15  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %for.cond.cleanup3 ], [ 0, %for.body4.preheader.preheader ]
16  br label %for.body4
17
18for.body4:                                        ; preds = %for.body4.preheader4, %for.body4
19  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 0, %for.body4.preheader4 ]
20  tail call void @test2(i64 %indvars.iv28, i64 %indvars.iv)
21  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
22  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
23  br i1 %exitcond.not, label %for.cond.cleanup3, label %for.body4
24
25for.cond.cleanup3:                                ; preds = %for.body4
26  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
27  %exitcond31.not = icmp eq i64 %indvars.iv.next29, 10
28  br i1 %exitcond31.not, label %for.cond.cleanup, label %for.body4.preheader4, !llvm.loop !1
29
30for.cond.cleanup:                                 ; preds = %for.cond.cleanup3
31  ret i32 55
32}
33
34
35; CHECK: F[test_02]
36; CHECK-NOT: Not unrolling loop since {{.*}}  llvm.loop.unroll_and_jam
37define i32 @test_02() {
38for.body4.preheader.preheader:
39  br label %for.body4.preheader4
40
41for.body4.preheader4:                             ; preds = %for.cond.cleanup3, %for.body4.preheader.preheader
42  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %for.cond.cleanup3 ], [ 0, %for.body4.preheader.preheader ]
43  br label %for.body4
44
45for.body4:                                        ; preds = %for.body4.preheader4, %for.body4
46  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 0, %for.body4.preheader4 ]
47  tail call void @test2(i64 %indvars.iv28, i64 %indvars.iv)
48  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
49  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
50  br i1 %exitcond.not, label %for.cond.cleanup3, label %for.body4
51
52for.cond.cleanup3:                                ; preds = %for.body4
53  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
54  %exitcond31.not = icmp eq i64 %indvars.iv.next29, 10
55  br i1 %exitcond31.not, label %for.cond.cleanup, label %for.body4.preheader4, !llvm.loop !2
56
57for.cond.cleanup:                                 ; preds = %for.cond.cleanup3
58  ret i32 55
59}
60
61; CHECK:F[test_03]
62; CHECK-NOT: Not unrolling loop since {{.*}}  llvm.loop.unroll_and_jam
63define i32 @test_03() {
64for.body4.preheader.preheader:
65  br label %for.body4.preheader4
66
67for.body4.preheader4:                             ; preds = %for.cond.cleanup3, %for.body4.preheader.preheader
68  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %for.cond.cleanup3 ], [ 0, %for.body4.preheader.preheader ]
69  br label %for.body4
70
71for.body4:                                        ; preds = %for.body4.preheader4, %for.body4
72  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 0, %for.body4.preheader4 ]
73  tail call void @test2(i64 %indvars.iv28, i64 %indvars.iv)
74  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
75  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
76  br i1 %exitcond.not, label %for.cond.cleanup3, label %for.body4
77
78for.cond.cleanup3:                                ; preds = %for.body4
79  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
80  %exitcond31.not = icmp eq i64 %indvars.iv.next29, 10
81  br i1 %exitcond31.not, label %for.cond.cleanup, label %for.body4.preheader4, !llvm.loop !3
82
83for.cond.cleanup:                                 ; preds = %for.cond.cleanup3
84  ret i32 55
85}
86
87declare void @test2(i64 signext, i64 signext)
88
89!1 = distinct !{!1, !4}
90!2 = distinct !{!1, !5}
91!3 = distinct !{!1, !6}
92!4 = !{!"llvm.loop.unroll_and_jam.count", i32 4}
93!5 = !{!"llvm.loop.unroll_and_jam.count", i32 1}
94!6 = !{!"llvm.loop.unroll_and_jam.disable"}
95