llvm-project
67 строк · 1.8 Кб
1; RUN: opt %loadNPMPolly '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s --check-prefix=AST
2; RUN: opt %loadNPMPolly -S -passes=polly-codegen < %s | FileCheck %s
3;
4; void jd(int *A, int c) {
5; for (int i = 0; i < 1024; i++) {
6; if (c)
7; A[i] = 1;
8; else
9; A[i] = 2;
10; }
11; }
12
13; AST: for (int c0 = 0; c0 <= 1023; c0 += 1) {
14; AST: if (c <= -1 || c >= 1) {
15; AST: Stmt_if_then(c0);
16; AST: } else
17; AST: Stmt_if_else(c0);
18; AST: Stmt_if_end(c0);
19; AST: }
20;
21; CHECK-LABEL: entry:
22; CHECK-NEXT: %phi.phiops = alloca i32
23; CHECK-LABEL: polly.stmt.if.end:
24; CHECK-NEXT: %phi.phiops.reload = load i32, ptr %phi.phiops
25; CHECK: %scevgep
26; CHECK-NEXT: store i32 %phi.phiops.reload, ptr
27; CHECK-LABEL: polly.stmt.if.then:
28; CHECK-NEXT: store i32 1, ptr %phi.phiops
29; CHECK-NEXT: br label %polly.merge{{[.]?}}
30; CHECK-LABEL: polly.stmt.if.else:
31; CHECK-NEXT: store i32 2, ptr %phi.phiops
32; CHECK-NEXT: br label %polly.merge{{[.]?}}
33;
34target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
35
36define void @jd(ptr %A, i32 %c) {
37entry:
38br label %for.cond
39
40for.cond:
41%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
42%exitcond = icmp ne i64 %indvars.iv, 1024
43br i1 %exitcond, label %for.body, label %for.end
44
45for.body:
46%tobool = icmp eq i32 %c, 0
47br i1 %tobool, label %if.else, label %if.then
48
49if.then:
50br label %if.end
51
52if.else:
53br label %if.end
54
55if.end:
56%phi = phi i32 [ 1, %if.then], [ 2, %if.else ]
57%arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
58store i32 %phi, ptr %arrayidx, align 4
59br label %for.inc
60
61for.inc:
62%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
63br label %for.cond
64
65for.end:
66ret void
67}
68