xref: /llvm-project/polly/test/CodeGen/single_loop_ll_max_iterations.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s
2
3;#include "limits.h"
4;#define N 20
5;
6;int main () {
7;  long long i;
8;  long long A[N];
9;
10;  A[0] = 0;
11;
12;  __sync_synchronize();
13;
14;  for (i = 0; i < LLONG_MAX; i++)
15;    A[0] = i;
16;
17;  __sync_synchronize();
18;
19;  if (A[0] == LLONG_MAX - 1)
20;    return 0;
21;  else
22;    return 1;
23;}
24
25target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
26
27define i32 @main() nounwind {
28entry:
29  %A = alloca [20 x i64], align 8                 ; <ptr> [#uses=3]
30  %arraydecay = getelementptr inbounds [20 x i64], ptr %A, i32 0, i32 0 ; <ptr> [#uses=1]
31  %arrayidx = getelementptr inbounds i64, ptr %arraydecay, i64 0 ; <ptr> [#uses=1]
32  store i64 0, ptr %arrayidx
33  fence seq_cst
34  br label %for.cond
35
36for.cond:                                         ; preds = %for.inc, %entry
37  %0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]  ; <i64> [#uses=3]
38  %exitcond = icmp ne i64 %0, 9223372036854775807 ; <i1> [#uses=1]
39  br i1 %exitcond, label %for.body, label %for.end
40
41for.body:                                         ; preds = %for.cond
42  %arraydecay2 = getelementptr inbounds [20 x i64], ptr %A, i32 0, i32 0 ; <ptr> [#uses=1]
43  %arrayidx3 = getelementptr inbounds i64, ptr %arraydecay2, i64 0 ; <ptr> [#uses=1]
44  store i64 %0, ptr %arrayidx3
45  br label %for.inc
46
47for.inc:                                          ; preds = %for.body
48  %inc = add nsw i64 %0, 1                        ; <i64> [#uses=1]
49  br label %for.cond
50
51for.end:                                          ; preds = %for.cond
52  fence seq_cst
53  %arraydecay5 = getelementptr inbounds [20 x i64], ptr %A, i32 0, i32 0 ; <ptr> [#uses=1]
54  %arrayidx6 = getelementptr inbounds i64, ptr %arraydecay5, i64 0 ; <ptr> [#uses=1]
55  %tmp7 = load i64, ptr %arrayidx6                    ; <i64> [#uses=1]
56  %cmp8 = icmp eq i64 %tmp7, 9223372036854775806  ; <i1> [#uses=1]
57  br i1 %cmp8, label %if.then, label %if.else
58
59if.then:                                          ; preds = %for.end
60  br label %return
61
62if.else:                                          ; preds = %for.end
63  br label %return
64
65return:                                           ; preds = %if.else, %if.then
66  %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.else ] ; <i32> [#uses=1]
67  ret i32 %retval.0
68}
69
70; CHECK: for (int c0 = 0; c0 <= 9223372036854775806; c0 += 1)
71; CHECK:   Stmt_for_body(c0);
72