[ScopBuilder/Simplify] Refactor isEscaping. NFC.
[polly-mirror.git] / test / ScopInfo / assume_gep_bounds_2.ll
blobd364211bc54803373060998916bd1cec98050967
1 ; RUN: opt %loadPolly -basicaa -polly-scops -analyze < %s \
2 ; RUN:  -polly-precise-inbounds | FileCheck %s
4 ;    void foo(float A[restrict][20], float B[restrict][20], long n, long m,
5 ;             long p) {
6 ;      for (long i = 0; i < n; i++)
7 ;        for (long j = 0; j < m; j++)
8 ;          A[i][j] = i + j;
9 ;      for (long i = 0; i < m; i++)
10 ;        for (long j = 0; j < p; j++)
11 ;          B[i][j] = i + j;
12 ;    }
14 ; This code is within bounds either if m and p are smaller than the array sizes,
15 ; but also if only p is smaller than the size of the second B dimension and n
16 ; is such that the first loop is never executed and consequently A is never
17 ; accessed. In this case the value of m does not matter.
19 ; CHECK:      Assumed Context:
20 ; CHECK-NEXT: [n, m, p] -> {  : p <= 20 and (n <= 0 or (n > 0 and m <= 20)) }
22 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
24 define void @foo([20 x float]* noalias %A, [20 x float]* noalias %B, i64 %n, i64 %m, i64 %p) {
25 entry:
26   br label %for.cond
28 for.cond:                                         ; preds = %for.inc5, %entry
29   %i.0 = phi i64 [ 0, %entry ], [ %inc6, %for.inc5 ]
30   %cmp = icmp slt i64 %i.0, %n
31   br i1 %cmp, label %for.body, label %for.end7
33 for.body:                                         ; preds = %for.cond
34   br label %for.cond1
36 for.cond1:                                        ; preds = %for.inc, %for.body
37   %j.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ]
38   %cmp2 = icmp slt i64 %j.0, %m
39   br i1 %cmp2, label %for.body3, label %for.end
41 for.body3:                                        ; preds = %for.cond1
42   %add = add nsw i64 %i.0, %j.0
43   %conv = sitofp i64 %add to float
44   %arrayidx4 = getelementptr inbounds [20 x float], [20 x float]* %A, i64 %i.0, i64 %j.0
45   store float %conv, float* %arrayidx4, align 4
46   br label %for.inc
48 for.inc:                                          ; preds = %for.body3
49   %inc = add nsw i64 %j.0, 1
50   br label %for.cond1
52 for.end:                                          ; preds = %for.cond1
53   br label %for.inc5
55 for.inc5:                                         ; preds = %for.end
56   %inc6 = add nsw i64 %i.0, 1
57   br label %for.cond
59 for.end7:                                         ; preds = %for.cond
60   br label %for.cond9
62 for.cond9:                                        ; preds = %for.inc25, %for.end7
63   %i8.0 = phi i64 [ 0, %for.end7 ], [ %inc26, %for.inc25 ]
64   %cmp10 = icmp slt i64 %i8.0, %m
65   br i1 %cmp10, label %for.body12, label %for.end27
67 for.body12:                                       ; preds = %for.cond9
68   br label %for.cond14
70 for.cond14:                                       ; preds = %for.inc22, %for.body12
71   %j13.0 = phi i64 [ 0, %for.body12 ], [ %inc23, %for.inc22 ]
72   %cmp15 = icmp slt i64 %j13.0, %p
73   br i1 %cmp15, label %for.body17, label %for.end24
75 for.body17:                                       ; preds = %for.cond14
76   %add18 = add nsw i64 %i8.0, %j13.0
77   %conv19 = sitofp i64 %add18 to float
78   %arrayidx21 = getelementptr inbounds [20 x float], [20 x float]* %B, i64 %i8.0, i64 %j13.0
79   store float %conv19, float* %arrayidx21, align 4
80   br label %for.inc22
82 for.inc22:                                        ; preds = %for.body17
83   %inc23 = add nsw i64 %j13.0, 1
84   br label %for.cond14
86 for.end24:                                        ; preds = %for.cond14
87   br label %for.inc25
89 for.inc25:                                        ; preds = %for.end24
90   %inc26 = add nsw i64 %i8.0, 1
91   br label %for.cond9
93 for.end27:                                        ; preds = %for.cond9
94   ret void