llvm-project
62 строки · 2.3 Кб
1; RUN: opt %loadNPMPolly '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s
2; RUN: opt %loadNPMPolly -passes=polly-codegen -S < %s | FileCheck %s -check-prefix=CODEGEN
3; RUN: opt %loadNPMPolly -passes=polly-codegen < %s | opt -passes='print<loops>' -disable-output 2>&1 | FileCheck %s -check-prefix=LOOPS
4target 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"
5
6@A = common global [1024 x i32] zeroinitializer
7
8define void @bar(i64 %n) {
9start:
10%n_plus_one = add i64 %n, 1
11fence seq_cst
12br label %loop.header
13
14loop.header:
15%i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
16%scevgep = getelementptr [1024 x i32], ptr @A, i64 0, i64 %i
17%exitcond = icmp ne i64 %i, %n_plus_one
18br i1 %exitcond, label %loop.body, label %ret
19
20loop.body:
21store i32 1, ptr %scevgep
22br label %loop.backedge
23
24loop.backedge:
25%i.next = add nsw i64 %i, 1
26br label %loop.header
27
28ret:
29fence seq_cst
30ret void
31}
32
33; CHECK: for (int c0 = 0; c0 <= n; c0 += 1)
34; CHECK: Stmt_loop_body(c0)
35
36; CODEGEN: polly.start:
37; CODEGEN: br label %polly.loop_if
38
39; CODEGEN: polly.loop_exit:
40; CODEGEN: br label %polly.merge_new_and_old
41
42; CODEGEN: polly.loop_if:
43; CODEGEN: %polly.loop_guard = icmp sle i64 0, %n
44; CODEGEN: br i1 %polly.loop_guard, label %polly.loop_preheader, label %polly.loop_exit
45
46; CODEGEN: polly.loop_header:
47; CODEGEN: %polly.indvar = phi i64 [ 0, %polly.loop_preheader ], [ %polly.indvar_next, %polly.stmt.loop.body ]
48; CODEGEN: br label %polly.stmt.loop.body
49
50; CODEGEN: polly.stmt.loop.body:
51; CODEGEN: %[[offset:.*]] = shl i64 %polly.indvar, 2
52; CODEGEN: [[PTR:%[a-zA-Z0-9_\.]+]] = getelementptr i8, ptr @A, i64 %[[offset]]
53; CODEGEN: store i32 1, ptr [[PTR]]
54; CODEGEN: %polly.indvar_next = add nsw i64 %polly.indvar, 1
55; CODEGEN: %polly.loop_cond = icmp sle i64 %polly.indvar_next, %n
56; CODEGEN: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
57
58; CODEGEN: polly.loop_preheader:
59; CODEGEN: br label %polly.loop_header
60
61; LOOPS-DAG: Loop at depth 1 containing: %loop.header<header><exiting>,%loop.body,%loop.backedge<latch>
62; LOOPS-DAG: Loop at depth 1 containing: %polly.loop_header<header>,%polly.stmt.loop.body<latch><exiting>
63