• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -pass-remarks-analysis="polly-scops" -polly-scops -disable-output < %s 2>&1 | FileCheck %s
2; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s --check-prefix=SCOP
3;
4; CHECK:      remark: <unknown>:0:0: SCoP begins here.
5; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: [M, N] -> {  : N <= 2147483647 - M }
6; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: [M, N] -> {  : -2147483648 - M <= N <= 2147483647 - M }
7; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: [M, N, Debug] -> {  : Debug = 0 and 0 < M <= 100 and -2147483648 - M <= N <= 2147483647 - M }
8; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: [M, N, Debug] -> {  : Debug = 0 and 0 < M <= 100 and 0 < N <= 2147483647 - M }
9; CHECK-NEXT: remark: <unknown>:0:0: SCoP ends here.
10
11; SCOP:      Context:
12; SCOP-NEXT: [N, M, Debug] -> { : Debug = 0 and N > 0 and 0 < M <= 2147483647 - N and M <= 100 }
13; SCOP:      Assumed Context:
14; SCOP-NEXT: [N, M, Debug] -> {  :  }
15; SCOP:      Invalid Context:
16; SCOP-NEXT: [N, M, Debug] -> {  : false }
17;
18;    #include <stdio.h>
19;
20;    void valid(int * restrict A, int * restrict B, int N, int M, int C[100][100], int Debug) {
21;      __builtin_assume(M <= 2147483647 - N);
22;      __builtin_assume(M >= -2147483648 - N);
23;      __builtin_assume(Debug == 0 && M <= 100 && M >= 1 && N >= 1);
24;      if (N + M == -1)
25;        C[0][0] = 0;
26;
27;      for (int i = 0; i < N; i++) {
28;        for (int j = 0; j != M; j++) {
29;          C[i][j] += A[i * M + j] + B[i + j];
30;        }
31;
32;        if (Debug)
33;          printf("Printf!");
34;      }
35;    }
36;
37target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38
39@.str = private unnamed_addr constant [8 x i8] c"Printf!\00", align 1
40
41define void @valid(i32* noalias %A, i32* noalias %B, i32 %N, i32 %M, [100 x i32]* %C, i32 %Debug) {
42entry:
43  %sub = sub nsw i32 2147483647, %N
44  %cmp = icmp sge i32 %sub, %M
45  call void @llvm.assume(i1 %cmp)
46  %conv = sext i32 %M to i64
47  %conv1 = sext i32 %N to i64
48  %sub2 = sub nsw i64 -2147483648, %conv1
49  %cmp3 = icmp sge i64 %conv, %sub2
50  call void @llvm.assume(i1 %cmp3)
51  %cmp5 = icmp eq i32 %Debug, 0
52  %cmp7 = icmp slt i32 %M, 101
53  %or.cond = and i1 %cmp5, %cmp7
54  %cmp10 = icmp sgt i32 %M, 0
55  %or.cond1 = and i1 %or.cond, %cmp10
56  %cmp12 = icmp sgt i32 %N, 0
57  call void @llvm.assume(i1 %or.cond1)
58  call void @llvm.assume(i1 %cmp12)
59  %add = add nsw i32 %N, %M
60  %cmp14 = icmp eq i32 %add, -1
61  br label %entry.split
62
63entry.split:
64  br i1 %cmp14, label %if.then, label %if.end
65
66if.then:                                          ; preds = %entry
67  %arrayidx16 = getelementptr inbounds [100 x i32], [100 x i32]* %C, i64 0, i64 0
68  store i32 0, i32* %arrayidx16, align 4
69  br label %if.end
70
71if.end:                                           ; preds = %if.then, %entry
72  %M64 = sext i32 %M to i64
73  %N64 = sext i32 %N to i64
74  br label %for.cond
75
76for.cond:                                         ; preds = %for.inc.36, %if.end
77  %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.36 ], [ 0, %if.end ]
78  %cmp17 = icmp slt i64 %indvars.iv3, %N64
79  br i1 %cmp17, label %for.cond.19, label %for.end.38
80
81for.cond.19:                                      ; preds = %for.cond, %for.body.22
82  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.22 ], [ 0, %for.cond ]
83  %cmp20 = icmp eq i64 %indvars.iv, %M64
84  br i1 %cmp20, label %for.end, label %for.body.22
85
86for.body.22:                                      ; preds = %for.cond.19
87  %tmp9 = mul nsw i64 %indvars.iv3, %M64
88  %tmp10 = add nsw i64 %tmp9, %indvars.iv
89  %arrayidx24 = getelementptr inbounds i32, i32* %A, i64 %tmp10
90  %tmp11 = load i32, i32* %arrayidx24, align 4
91  %tmp12 = add nuw nsw i64 %indvars.iv3, %indvars.iv
92  %arrayidx27 = getelementptr inbounds i32, i32* %B, i64 %tmp12
93  %tmp13 = load i32, i32* %arrayidx27, align 4
94  %add28 = add nsw i32 %tmp11, %tmp13
95  %arrayidx32 = getelementptr inbounds [100 x i32], [100 x i32]* %C, i64 %indvars.iv3, i64 %indvars.iv
96  %tmp14 = load i32, i32* %arrayidx32, align 4
97  %add33 = add nsw i32 %tmp14, %add28
98  store i32 %add33, i32* %arrayidx32, align 4
99  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
100  br label %for.cond.19
101
102for.end:                                          ; preds = %for.cond.19
103  %tobool = icmp eq i32 %Debug, 0
104  br i1 %tobool, label %for.inc.36, label %if.then.34
105
106if.then.34:                                       ; preds = %for.end
107  %call = call i32 (i8*, ...) @printf(i8* nonnull getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
108  br label %for.inc.36
109
110for.inc.36:                                       ; preds = %for.end, %if.then.34
111  %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1
112  br label %for.cond
113
114for.end.38:                                       ; preds = %for.cond
115  ret void
116}
117
118; Function Attrs: nounwind
119declare void @llvm.assume(i1) #0
120
121declare i32 @printf(i8*, ...)
122
123attributes #0 = { nounwind }
124