llvm-project
92 строки · 2.6 Кб
1; RUN: opt %loadNPMPolly '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s
2
3;#define N 20
4;#include "limits.h"
5;#include <stdio.h>
6;int A[N];
7;
8;void single_do_loop_int_max_iterations() {
9; int i;
10;
11; __sync_synchronize();
12;
13; i = 0;
14;
15; do {
16; A[0] = i;
17; ++i;
18; } while (i < INT_MAX);
19;
20; __sync_synchronize();
21;}
22;
23;int main () {
24; int i;
25;
26; A[0] = 0;
27;
28; single_do_loop_int_max_iterations();
29;
30; fprintf(stdout, "Output %d\n", A[0]);
31;
32; if (A[0] == INT_MAX - 1)
33; return 0;
34; else
35; return 1;
36;}
37
38target 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"
39
40%struct._IO_FILE = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i16, i8, [1 x i8], ptr, i64, ptr, ptr, ptr, ptr, i64, i32, [20 x i8] }
41%struct._IO_marker = type { ptr, ptr, i32 }
42
43@A = common global [20 x i32] zeroinitializer, align 4 ; <ptr> [#uses=1]
44@stdout = external global ptr ; <ptr> [#uses=1]
45@.str = private constant [11 x i8] c"Output %d\0A\00" ; <ptr> [#uses=1]
46
47define void @single_do_loop_int_max_iterations() nounwind {
48entry:
49fence seq_cst
50br label %do.body
51
52do.body: ; preds = %do.cond, %entry
53%0 = phi i32 [ 0, %entry ], [ %inc, %do.cond ] ; <i32> [#uses=2]
54store i32 %0, ptr @A
55%inc = add nsw i32 %0, 1 ; <i32> [#uses=2]
56br label %do.cond
57
58do.cond: ; preds = %do.body
59%exitcond = icmp ne i32 %inc, 2147483647 ; <i1> [#uses=1]
60br i1 %exitcond, label %do.body, label %do.end
61
62do.end: ; preds = %do.cond
63fence seq_cst
64ret void
65}
66
67define i32 @main() nounwind {
68entry:
69store i32 0, ptr @A
70call void @single_do_loop_int_max_iterations()
71%tmp = load ptr, ptr @stdout ; <ptr> [#uses=1]
72%tmp1 = load i32, ptr @A ; <i32> [#uses=1]
73%call = call i32 (ptr, ptr, ...) @fprintf(ptr %tmp, ptr @.str, i32 %tmp1) ; <i32> [#uses=0]
74%tmp2 = load i32, ptr @A ; <i32> [#uses=1]
75%cmp = icmp eq i32 %tmp2, 2147483646 ; <i1> [#uses=1]
76br i1 %cmp, label %if.then, label %if.else
77
78if.then: ; preds = %entry
79br label %return
80
81if.else: ; preds = %entry
82br label %return
83
84return: ; preds = %if.else, %if.then
85%retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.else ] ; <i32> [#uses=1]
86ret i32 %retval.0
87}
88
89declare i32 @fprintf(ptr, ptr, ...)
90
91; CHECK: for (int c0 = 0; c0 <= 2147483646; c0 += 1)
92; CHECK: Stmt_do_body(c0);
93