xref: /llvm-project/polly/test/CodeGen/OpenMP/loop-body-references-outer-values-3.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-parallel -polly-parallel-force -polly-invariant-load-hoisting=true '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s -check-prefix=AST
2; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-parallel -polly-parallel-force -polly-invariant-load-hoisting=true -passes=polly-codegen -S -verify-dom-info < %s | FileCheck %s -check-prefix=IR
3
4; The interesting part of this test case is the instruction:
5;   %tmp = bitcast i8* %call to i64**
6; which is not part of the scop. In the SCEV based code generation not '%tmp',
7; but %call is a parameter of the SCoP and we need to make sure its value is
8; properly forwarded to the subfunction.
9
10; AST: #pragma omp parallel for
11; AST: for (int c0 = 0; c0 < cols; c0 += 1)
12; AST:   Stmt_for_body(c0);
13; AST: if (cols <= 0)
14; AST:   Stmt_for_body(0);
15
16; IR: @foo_polly_subfn
17
18target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19
20define void @foo(i64 %cols, ptr noalias %call) {
21entry:
22  br label %for.body
23
24for.body:
25  %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %entry ]
26  %tmp1 = load ptr, ptr %call, align 8
27  %arrayidx.2 = getelementptr inbounds i64, ptr %tmp1, i64 %indvar
28  store i64 1, ptr %arrayidx.2, align 4
29  %indvar.next = add nsw i64 %indvar, 1
30  %cmp = icmp slt i64 %indvar.next, %cols
31  br i1 %cmp, label %for.body, label %end
32
33end:
34  ret void
35}
36
37; Another variation of this test case, now with even more of the index
38; expression defined outside of the scop.
39
40; AST: #pragma omp parallel for
41; AST: for (int c0 = 0; c0 < cols; c0 += 1)
42; AST:   Stmt_for_body(c0);
43; AST: if (cols <= 0)
44; AST:   Stmt_for_body(0);
45
46; IR: @bar_polly_subfn
47
48define void @bar(i64 %cols, ptr noalias %call) {
49entry:
50  br label %for.body
51
52for.body:
53  %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %entry ]
54  %tmp1 = load ptr, ptr %call, align 8
55  %arrayidx.2 = getelementptr inbounds i64, ptr %tmp1, i64 %indvar
56  store i64 1, ptr %arrayidx.2, align 4
57  %indvar.next = add nsw i64 %indvar, 1
58  %cmp = icmp slt i64 %indvar.next, %cols
59  br i1 %cmp, label %for.body, label %end
60
61end:
62  ret void
63}
64