• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -analyze -polly-use-llvm-names -polly-scops -polly-invariant-load-hoisting < %s | FileCheck %s -check-prefix=SCOP
2; RUN: opt %loadPolly -S -polly-use-llvm-names -polly-codegen-ppcg -polly-invariant-load-hoisting < %s | FileCheck %s -check-prefix=HOST-IR
3
4; REQUIRES: pollyacc
5
6; Check that we detect a scop with invariant accesses.
7; SCOP:      Function: f
8; SCOP-NEXT: Region: %entry.split---%for.end
9; SCOP-NEXT: Max Loop Depth:  1
10; SCOP-NEXT: Invariant Accesses: {
11; SCOP-NEXT:         ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
12; SCOP-NEXT:             [tmp2] -> { Stmt_for_body[i0] -> MemRef_idx[0] };
13; SCOP-NEXT:         Execution Context: [tmp2] -> {  :  }
14; SCOP-NEXT: }
15
16; Check that kernel launch is generated in host IR.
17; the declare would not be generated unless a call to a kernel exists.
18; HOST-IR: declare void @polly_launchKernel(i8*, i32, i32, i32, i32, i32, i8*)
19
20; Check if we generate GPU code for simple loop with variable upper bound.
21; This always worked, but have this test to prevent regressions.
22;    void f(int *idx, int *arr) {
23;      for (int i = 0; i < *idx; i++) {
24;        arr[i] = 0;
25;      }
26;    }
27;
28target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
29
30define void @f(i32* %idx, i32* %arr) {
31entry:
32  br label %entry.split
33
34entry.split:                                      ; preds = %entry
35  %tmp21 = load i32, i32* %idx, align 4
36  %cmp2 = icmp sgt i32 %tmp21, 0
37  br i1 %cmp2, label %for.body.lr.ph, label %for.end
38
39for.body.lr.ph:                                   ; preds = %entry.split
40  br label %for.body
41
42for.body:                                         ; preds = %for.body.lr.ph, %for.body
43  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
44  %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %indvars.iv
45  store i32 0, i32* %arrayidx, align 4
46  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
47  %tmp2 = load i32, i32* %idx, align 4
48  %0 = sext i32 %tmp2 to i64
49  %cmp = icmp slt i64 %indvars.iv.next, %0
50  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
51
52for.cond.for.end_crit_edge:                       ; preds = %for.body
53  br label %for.end
54
55for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry.split
56  ret void
57}
58