[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / test / Analysis / ScalarEvolution / lt-overflow.ll
blob58c2cc3e1da21e5abd0267a77088b41f7a2fd792
1 ; RUN: opt %s -passes='print<scalar-evolution>' -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
3 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; A collection of tests focused on exercising logic to prove no-unsigned wrap
7 ; from mustprogress semantics of loops.
9 ; CHECK: Determining loop execution counts for: @test
10 ; CHECK: Loop %for.body: backedge-taken count is ((-1 + (2 umax %N)) /u 2)
11 ; CHECK: Determining loop execution counts for: @test_preinc
12 ; CHECK: Loop %for.body: backedge-taken count is ((1 + %N) /u 2)
13 ; CHECK: Determining loop execution counts for: @test_well_defined_infinite_st
14 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
15 ; CHECK: Determining loop execution counts for: @test_well_defined_infinite_ld
16 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
17 ; CHECK: Determining loop execution counts for: @test_no_mustprogress
18 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
19 ; CHECK: Determining loop execution counts for: @test_1024
20 ; CHECK: Loop %for.body: backedge-taken count is ((-1 + (1024 umax %N)) /u 1024)
21 ; CHECK: Determining loop execution counts for: @test_uneven_divide
22 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
23 ; CHECK: Determining loop execution counts for: @test_non_invariant_rhs
24 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
25 ; CHECK: Determining loop execution counts for: @test_abnormal_exit
26 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
27 ; CHECK: Determining loop execution counts for: @test_other_exit
28 ; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count.
29 ; CHECK: Determining loop execution counts for: @test_gt
30 ; CHECK: Loop %for.body: Unpredictable backedge-taken count.
32 define void @test(i32 %N) mustprogress {
33 entry:
34   br label %for.body
36 for.body:
37   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
38   %iv.next = add i32 %iv, 2
39   %cmp = icmp ult i32 %iv.next, %N
40   br i1 %cmp, label %for.body, label %for.cond.cleanup
42 for.cond.cleanup:
43   ret void
46 define void @test_preinc(i32 %N) mustprogress {
47 entry:
48   br label %for.body
50 for.body:
51   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
52   %iv.next = add i32 %iv, 2
53   %cmp = icmp ult i32 %iv, %N
54   br i1 %cmp, label %for.body, label %for.cond.cleanup
56 for.cond.cleanup:
57   ret void
61 @G = external global i32
63 define void @test_well_defined_infinite_st(i32 %N) mustprogress {
64 entry:
65   br label %for.body
67 for.body:
68   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
69   %iv.next = add i32 %iv, 2
70   store volatile i32 0, i32* @G
71   %cmp = icmp ult i32 %iv.next, %N
72   br i1 %cmp, label %for.body, label %for.cond.cleanup
74 for.cond.cleanup:
75   ret void
78 define void @test_well_defined_infinite_ld(i32 %N) mustprogress {
79 entry:
80   br label %for.body
82 for.body:
83   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
84   %iv.next = add i32 %iv, 2
85   %val = load volatile i32, i32* @G
86   %cmp = icmp ult i32 %iv.next, %N
87   br i1 %cmp, label %for.body, label %for.cond.cleanup
89 for.cond.cleanup:
90   ret void
93 define void @test_no_mustprogress(i32 %N) {
94 entry:
95   br label %for.body
97 for.body:
98   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
99   %iv.next = add i32 %iv, 2
100   %cmp = icmp ult i32 %iv.next, %N
101   br i1 %cmp, label %for.body, label %for.cond.cleanup
103 for.cond.cleanup:
104   ret void
109 define void @test_1024(i32 %N) mustprogress {
110 entry:
111   br label %for.body
113 for.body:
114   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
115   %iv.next = add i32 %iv, 1024
116   %cmp = icmp ult i32 %iv.next, %N
117   br i1 %cmp, label %for.body, label %for.cond.cleanup
119 for.cond.cleanup:
120   ret void
123 define void @test_uneven_divide(i32 %N) mustprogress {
124 entry:
125   br label %for.body
127 for.body:
128   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
129   %iv.next = add i32 %iv, 3
130   %cmp = icmp ult i32 %iv.next, %N
131   br i1 %cmp, label %for.body, label %for.cond.cleanup
133 for.cond.cleanup:
134   ret void
137 define void @test_non_invariant_rhs() mustprogress {
138 entry:
139   br label %for.body
141 for.body:
142   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
143   %iv.next = add i32 %iv, 2
144   %N = load i32, i32* @G
145   %cmp = icmp ult i32 %iv.next, %N
146   br i1 %cmp, label %for.body, label %for.cond.cleanup
148 for.cond.cleanup:
149   ret void
152 declare void @mayexit()
154 define void @test_abnormal_exit(i32 %N) mustprogress {
155 entry:
156   br label %for.body
158 for.body:
159   %iv = phi i32 [ %iv.next, %for.body ], [ 0, %entry ]
160   %iv.next = add i32 %iv, 2
161   call void @mayexit()
162   %cmp = icmp ult i32 %iv.next, %N
163   br i1 %cmp, label %for.body, label %for.cond.cleanup
165 for.cond.cleanup:
166   ret void
170 define void @test_other_exit(i32 %N) mustprogress {
171 entry:
172   br label %for.body
174 for.body:
175   %iv = phi i32 [ %iv.next, %for.latch ], [ 0, %entry ]
176   %iv.next = add i32 %iv, 2
177   %cmp1 = icmp ult i32 %iv.next, 20
178   br i1 %cmp1, label %for.latch, label %for.cond.cleanup
180 for.latch:
181   %cmp2 = icmp ult i32 %iv.next, %N
182   br i1 %cmp2, label %for.body, label %for.cond.cleanup
184 for.cond.cleanup:
185   ret void
188 define void @test_gt(i32 %S, i32 %N) mustprogress {
189 entry:
190   br label %for.body
192 for.body:
193   %iv = phi i32 [ %iv.next, %for.body ], [ %S, %entry ]
194   %iv.next = add i32 %iv, -2
195   %cmp = icmp ugt i32 %iv.next, %N
196   br i1 %cmp, label %for.body, label %for.cond.cleanup
198 for.cond.cleanup:
199   ret void