15c028081SMichael Kruse; RUN: opt %loadPolly -polly-print-ast -disable-output < %s | FileCheck %s
235f70200SMichael Kruse; RUN: opt %loadPolly -polly-codegen  -S < %s | FileCheck %s -check-prefix=CODEGEN
3*caf6af2eSArthur Eubanks; RUN: opt %loadPolly -polly-codegen < %s | opt -passes='print<loops>' -disable-output 2>&1 | FileCheck %s -check-prefix=LOOPS
435f70200SMichael Krusetarget 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"
535f70200SMichael Kruse
635f70200SMichael Kruse@A = common global [1024 x i32] zeroinitializer
735f70200SMichael Kruse
835f70200SMichael Krusedefine void @bar(i64 %n) {
935f70200SMichael Krusestart:
1035f70200SMichael Kruse  %n_plus_one = add i64 %n, 1
1135f70200SMichael Kruse  fence seq_cst
1235f70200SMichael Kruse  br label %loop.header
1335f70200SMichael Kruse
1435f70200SMichael Kruseloop.header:
1535f70200SMichael Kruse  %i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
1635f70200SMichael Kruse  %scevgep = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %i
1735f70200SMichael Kruse  %exitcond = icmp ne i64 %i, %n_plus_one
1835f70200SMichael Kruse  br i1 %exitcond, label %loop.body, label %ret
1935f70200SMichael Kruse
2035f70200SMichael Kruseloop.body:
2135f70200SMichael Kruse  store i32 1, i32* %scevgep
2235f70200SMichael Kruse  br label %loop.backedge
2335f70200SMichael Kruse
2435f70200SMichael Kruseloop.backedge:
2535f70200SMichael Kruse  %i.next = add nsw i64 %i, 1
2635f70200SMichael Kruse  br label %loop.header
2735f70200SMichael Kruse
2835f70200SMichael Kruseret:
2935f70200SMichael Kruse  fence seq_cst
3035f70200SMichael Kruse  ret void
3135f70200SMichael Kruse}
3235f70200SMichael Kruse
3335f70200SMichael Kruse; CHECK: for (int c0 = 0; c0 <= n; c0 += 1)
3435f70200SMichael Kruse; CHECK:   Stmt_loop_body(c0)
3535f70200SMichael Kruse
3635f70200SMichael Kruse; CODEGEN: polly.start:
3735f70200SMichael Kruse; CODEGEN:   br label %polly.loop_if
3835f70200SMichael Kruse
3935f70200SMichael Kruse; CODEGEN: polly.loop_exit:
4035f70200SMichael Kruse; CODEGEN:   br label %polly.merge_new_and_old
4135f70200SMichael Kruse
4235f70200SMichael Kruse; CODEGEN: polly.loop_if:
4335f70200SMichael Kruse; CODEGEN:   %polly.loop_guard = icmp sle i64 0, %n
4435f70200SMichael Kruse; CODEGEN:   br i1 %polly.loop_guard, label %polly.loop_preheader, label %polly.loop_exit
4535f70200SMichael Kruse
4635f70200SMichael Kruse; CODEGEN: polly.loop_header:
4735f70200SMichael Kruse; CODEGEN:   %polly.indvar = phi i64 [ 0, %polly.loop_preheader ], [ %polly.indvar_next, %polly.stmt.loop.body ]
4835f70200SMichael Kruse; CODEGEN:   br label %polly.stmt.loop.body
4935f70200SMichael Kruse
5035f70200SMichael Kruse; CODEGEN: polly.stmt.loop.body:
5135f70200SMichael Kruse; CODEGEN:   [[PTR:%[a-zA-Z0-9_\.]+]] = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %polly.indvar
5235f70200SMichael Kruse; CODEGEN:   store i32 1, i32* [[PTR]]
5335f70200SMichael Kruse; CODEGEN:   %polly.indvar_next = add nsw i64 %polly.indvar, 1
5435f70200SMichael Kruse; CODEGEN:   %polly.loop_cond = icmp sle i64 %polly.indvar_next, %n
5535f70200SMichael Kruse; CODEGEN:   br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
5635f70200SMichael Kruse
5735f70200SMichael Kruse; CODEGEN: polly.loop_preheader:
5835f70200SMichael Kruse; CODEGEN:   br label %polly.loop_header
5935f70200SMichael Kruse
6035f70200SMichael Kruse; LOOPS-DAG: Loop at depth 1 containing: %loop.header<header><exiting>,%loop.body,%loop.backedge<latch>
6135f70200SMichael Kruse; LOOPS-DAG: Loop at depth 1 containing: %polly.loop_header<header>,%polly.stmt.loop.body<latch><exiting>
62