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