1 ; RUN: opt %loadPolly -pass-remarks-analysis="polly-scops" -polly-scops -disable-output < %s 2>&1 | FileCheck %s
2 ; RUN: opt %loadPolly -polly-print-scops -disable-output < %s | FileCheck %s --check-prefix=SCOP
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.
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 }
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);
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];
37 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39 @.str = private unnamed_addr constant [8 x i8] c"Printf!\00", align 1
41 define void @valid(ptr noalias %A, ptr noalias %B, i32 %N, i32 %M, ptr %C, i32 %Debug) {
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
64 br i1 %cmp14, label %if.then, label %if.end
66 if.then: ; preds = %entry
67 store i32 0, ptr %C, align 4
70 if.end: ; preds = %if.then, %entry
71 %M64 = sext i32 %M to i64
72 %N64 = sext i32 %N to i64
75 for.cond: ; preds = %for.inc.36, %if.end
76 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.36 ], [ 0, %if.end ]
77 %cmp17 = icmp slt i64 %indvars.iv3, %N64
78 br i1 %cmp17, label %for.cond.19, label %for.end.38
80 for.cond.19: ; preds = %for.cond, %for.body.22
81 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.22 ], [ 0, %for.cond ]
82 %cmp20 = icmp eq i64 %indvars.iv, %M64
83 br i1 %cmp20, label %for.end, label %for.body.22
85 for.body.22: ; preds = %for.cond.19
86 %tmp9 = mul nsw i64 %indvars.iv3, %M64
87 %tmp10 = add nsw i64 %tmp9, %indvars.iv
88 %arrayidx24 = getelementptr inbounds i32, ptr %A, i64 %tmp10
89 %tmp11 = load i32, ptr %arrayidx24, align 4
90 %tmp12 = add nuw nsw i64 %indvars.iv3, %indvars.iv
91 %arrayidx27 = getelementptr inbounds i32, ptr %B, i64 %tmp12
92 %tmp13 = load i32, ptr %arrayidx27, align 4
93 %add28 = add nsw i32 %tmp11, %tmp13
94 %arrayidx32 = getelementptr inbounds [100 x i32], ptr %C, i64 %indvars.iv3, i64 %indvars.iv
95 %tmp14 = load i32, ptr %arrayidx32, align 4
96 %add33 = add nsw i32 %tmp14, %add28
97 store i32 %add33, ptr %arrayidx32, align 4
98 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
101 for.end: ; preds = %for.cond.19
102 %tobool = icmp eq i32 %Debug, 0
103 br i1 %tobool, label %for.inc.36, label %if.then.34
105 if.then.34: ; preds = %for.end
106 %call = call i32 (ptr, ...) @printf(ptr nonnull @.str)
109 for.inc.36: ; preds = %for.end, %if.then.34
110 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1
113 for.end.38: ; preds = %for.cond
117 ; Function Attrs: nounwind
118 declare void @llvm.assume(i1) #0
120 declare i32 @printf(ptr, ...)
122 attributes #0 = { nounwind }