[JSON][PM] Port json import/export over to new pm
[polly-mirror.git] / test / GPGPU / add-scalars-in-scop-to-kills.ll
blobf3272dea19583141853e3c79a596374411e92218
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
4 ; REQUIRES: pollyacc
6 ; Check that we detect a scop.
7 ; SCOP:       Function: checkScalarKill
8 ; SCOP-NEXT: Region: %XLoopInit---%for.end
9 ; SCOP-NEXT: Max Loop Depth:  1
11 ; Check that we have a scalar that is not a phi node in the scop.
12 ; SCOP: i32 MemRef_x_0; // Element size 4
14 ; Check that kernel launch is generated in host IR.
15 ; the declare would not be generated unless a call to a kernel exists.
16 ; HOST-IR: declare void @polly_launchKernel(i8*, i32, i32, i32, i32, i32, i8*)
18 ; Check that we add variables that are local to a scop into the kills that we
19 ; pass to PPCG. This should enable PPCG to codegen this example.
20 ; void checkScalarKill(int A[], int B[], int C[], const int control1, int control2) {
21 ; int x;
22 ; #pragma scop
23 ;     for(int i = 0; i < 1000; i++) {
24 ; XLoopInit:        x = 0;
25
26 ;         if (control1 > 2)
27 ;             C1Add: x += 10;
28 ;         if (control2 > 3)
29 ;             C2Add: x += A[i];
30
31 ; BLoopAccumX:        B[i] += x;
32 ;     }
33
34 ; #pragma endscop
35 ; }
36 ; ModuleID = 'test.ll'
37 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
39 define void @checkScalarKill(i32* %A, i32* %B, i32* %C, i32 %control1, i32 %control2) {
40 entry:
41   br label %entry.split
43 entry.split:                                      ; preds = %entry
44   br label %XLoopInit
46 XLoopInit:                                        ; preds = %entry.split, %BLoopAccumX
47   %indvars.iv = phi i64 [ 0, %entry.split ], [ %indvars.iv.next, %BLoopAccumX ]
48   %cmp1 = icmp sgt i32 %control1, 2
49   %x.0 = select i1 %cmp1, i32 10, i32 0
50   %cmp2 = icmp sgt i32 %control2, 3
51   br i1 %cmp2, label %C2Add, label %BLoopAccumX
53 C2Add:                                            ; preds = %XLoopInit
54   %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
55   %tmp6 = load i32, i32* %arrayidx, align 4
56   %add4 = add nsw i32 %tmp6, %x.0
57   br label %BLoopAccumX
59 BLoopAccumX:                                      ; preds = %XLoopInit, %C2Add
60   %x.1 = phi i32 [ %add4, %C2Add ], [ %x.0, %XLoopInit ]
61   %arrayidx7 = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
62   %tmp11 = load i32, i32* %arrayidx7, align 4
63   %add8 = add nsw i32 %tmp11, %x.1
64   store i32 %add8, i32* %arrayidx7, align 4
65   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
66   %exitcond = icmp ne i64 %indvars.iv.next, 1000
67   br i1 %exitcond, label %XLoopInit, label %for.end
69 for.end:                                          ; preds = %BLoopAccumX
70   ret void