[ScopBuilder/Simplify] Refactor isEscaping. NFC.
[polly-mirror.git] / test / ScopInfo / user_provided_assumptions_3.ll
blobf16df2192183ef2bf170fd60c8b340e83749c6fe
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
4 ; CHECK:      remark: <unknown>:0:0: SCoP begins here.
5 ; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: [N] -> { : N >= 2 }
6 ; CHECK-NEXT: remark: <unknown>:0:0: SCoP ends here.
8 ; SCOP:      Context:
9 ; SCOP-NEXT: [N, M] -> { : 2 <= N <= 2147483647 and -2147483648 <= M <= 2147483647 }
10 ; SCOP:      Assumed Context:
11 ; SCOP-NEXT: [N, M] -> { : }
12 ; SCOP:      Invalid Context:
13 ; SCOP-NEXT: [N, M] -> { : 1 = 0 }
15 ;    int f(int *A, int N, int M) {
16 ;      __builtin_assume(M > 0 && N > M);
17 ;      for (int i = 0; i < N; i++)
18 ;        A[i]++;
19 ;      return M;
20 ;    }
22 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
24 define i32 @f(i32* %A, i32 %N, i32 %M) {
25 entry:
26   %cmp = icmp sgt i32 %M, 0
27   %cmp1 = icmp sgt i32 %N, %M
28   %and = and i1 %cmp, %cmp1
29   call void @llvm.assume(i1 %and)
30   %tmp1 = sext i32 %N to i64
31   br label %for.cond
33 for.cond:                                         ; preds = %for.inc, %land.end
34   %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
35   %cmp2 = icmp slt i64 %indvars.iv, %tmp1
36   br i1 %cmp2, label %for.body, label %for.end
38 for.body:                                         ; preds = %for.cond
39   %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
40   %tmp2 = load i32, i32* %arrayidx, align 4
41   %inc = add nsw i32 %tmp2, 1
42   store i32 %inc, i32* %arrayidx, align 4
43   br label %for.inc
45 for.inc:                                          ; preds = %for.body
46   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
47   br label %for.cond
49 for.end:                                          ; preds = %for.cond
50   ret i32 %M
53 declare void @llvm.assume(i1) #1