1; RUN: opt %loadPolly -analyze -polly-ast < %s | FileCheck %s --check-prefix=AST
2; RUN: opt %loadPolly -S -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, i32* %phi.phiops
25; CHECK-NEXT:     %scevgep
26; CHECK-NEXT:     store i32 %phi.phiops.reload, i32*
27; CHECK-LABEL:  polly.stmt.if.then:
28; CHECK-NEXT:     store i32 1, i32* %phi.phiops
29; CHECK-NEXT:     br label %polly.merge{{[.]?}}
30; CHECK-LABEL:  polly.stmt.if.else:
31; CHECK-NEXT:     store i32 2, i32* %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(i32* %A, i32 %c) {
37entry:
38  br 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
43  br i1 %exitcond, label %for.body, label %for.end
44
45for.body:
46  %tobool = icmp eq i32 %c, 0
47  br i1 %tobool, label %if.else, label %if.then
48
49if.then:
50  br label %if.end
51
52if.else:
53  br label %if.end
54
55if.end:
56  %phi = phi i32 [ 1, %if.then], [ 2, %if.else ]
57  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
58  store i32 %phi, i32* %arrayidx, align 4
59  br label %for.inc
60
61for.inc:
62  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
63  br label %for.cond
64
65for.end:
66  ret void
67}
68