• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s -check-prefix=SCOP
2; RUN: opt %loadPolly -S -polly-codegen-ppcg < %s | FileCheck %s -check-prefix=HOST-IR
3
4; REQUIRES: pollyacc
5
6; SCOP:      Function: f
7; SCOP-NEXT: Region: %for.body---%for.end
8; SCOP-NEXT: Max Loop Depth:  1
9
10; Check that kernel launch is generated in host IR.
11; the declare would not be generated unless a call to a kernel exists.
12; HOST-IR: declare void @polly_launchKernel(i8*, i32, i32, i32, i32, i32, i8*)
13
14; void f(int A[], int B[], int control, int C[]) {
15;     int x;
16; #pragma scop
17;     for(int i = 0; i < 1000; i ++) {
18;         x = 0;
19;         if(control) x = C[i];
20;         B[i] = x * A[i];
21;
22;     }
23; #pragma endscop
24; }
25
26target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
27
28define void @f(i32* %A, i32* %B, i32 %control, i32* %C) {
29entry:
30  br label %entry.split
31
32entry.split:                                      ; preds = %entry
33  br label %for.body
34
35for.body:                                         ; preds = %entry.split, %if.end
36  %indvars.iv = phi i64 [ 0, %entry.split ], [ %indvars.iv.next, %if.end ]
37  %tobool = icmp eq i32 %control, 0
38  br i1 %tobool, label %if.end, label %if.then
39
40if.then:                                          ; preds = %for.body
41  %arrayidx = getelementptr inbounds i32, i32* %C, i64 %indvars.iv
42  %tmp4 = load i32, i32* %arrayidx, align 4
43  br label %if.end
44
45if.end:                                           ; preds = %for.body, %if.then
46  %x.0 = phi i32 [ %tmp4, %if.then ], [ 0, %for.body ]
47  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
48  %tmp8 = load i32, i32* %arrayidx2, align 4
49  %mul = mul nsw i32 %tmp8, %x.0
50  %arrayidx4 = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
51  store i32 %mul, i32* %arrayidx4, align 4
52  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
53  %exitcond = icmp ne i64 %indvars.iv.next, 1000
54  br i1 %exitcond, label %for.body, label %for.end
55
56for.end:                                          ; preds = %if.end
57  ret void
58}
59