xref: /llvm-project/polly/test/ScopInliner/simple-inline-loop.ll (revision b332499a94df11870dfc7598645c59656deb933d)
1; RUN: opt %loadPolly -polly-detect-full-functions -polly-scop-inliner \
2; RUN: -polly-print-scops -disable-output < %s | FileCheck %s
3
4; Check that we get the 2 nested loops by inlining `to_be_inlined` into
5; `inline_site`.
6; CHECK:    Max Loop Depth:  2
7
8; static const int N = 1000;
9;
10; void to_be_inlined(int A[]) {
11;     for(int i = 0; i < N; i++)
12;         A[i] *= 10;
13; }
14;
15; void inline_site(int A[]) {
16;     for(int i = 0; i < N; i++)
17;         to_be_inlined(A);
18; }
19
20target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
21target triple = "x86_64-apple-macosx10.12.0"
22
23
24define void @to_be_inlined(ptr %A) {
25entry:
26  br label %entry.split
27
28entry.split:                                      ; preds = %entry
29  br label %for.body
30
31for.body:                                         ; preds = %entry.split, %for.body
32  %indvars.iv1 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next, %for.body ]
33  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv1
34  %tmp = load i32, ptr %arrayidx, align 4
35  %mul = mul nsw i32 %tmp, 10
36  store i32 %mul, ptr %arrayidx, align 4
37  %indvars.iv.next = add nuw nsw i64 %indvars.iv1, 1
38  %exitcond = icmp eq i64 %indvars.iv.next, 1000
39  br i1 %exitcond, label %for.end, label %for.body
40
41for.end:                                          ; preds = %for.body
42  ret void
43}
44
45define void @inline_site(ptr %A) {
46entry:
47  br label %entry.split
48
49entry.split:                                      ; preds = %entry
50  br label %for.body
51
52for.body:                                         ; preds = %entry.split, %for.body
53  %i.01 = phi i32 [ 0, %entry.split ], [ %inc, %for.body ]
54  tail call void @to_be_inlined(ptr %A)
55  %inc = add nuw nsw i32 %i.01, 1
56  %exitcond = icmp eq i32 %inc, 1000
57  br i1 %exitcond, label %for.end, label %for.body
58
59for.end:                                          ; preds = %for.body
60  ret void
61}
62
63