1 ; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s
3 ; int jd(int *restrict A, int x, int N, int c) {
4 ; for (int i = 0; i < N; i++)
5 ; for (int j = 0; j < N; j++)
11 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
13 define i32 @jd(ptr noalias %A, i32 %x, i32 %N, i32 %c) {
16 ; CHECK-DAG: %x.addr.2.s2a = alloca i32
17 ; CHECK-DAG: %x.addr.2.phiops = alloca i32
18 ; CHECK-DAG: %x.addr.1.s2a = alloca i32
19 ; CHECK-DAG: %x.addr.1.phiops = alloca i32
20 ; CHECK-DAG: %x.addr.0.s2a = alloca i32
21 ; CHECK-DAG: %x.addr.0.phiops = alloca i32
22 %tmp = sext i32 %N to i64
23 %tmp1 = sext i32 %c to i64
26 ; CHECK-LABEL: polly.merge_new_and_old:
27 ; CHECK: %x.addr.0.merge = phi i32 [ %x.addr.0.final_reload, %polly.exiting ], [ %x.addr.0, %for.cond ]
28 ; CHECK: ret i32 %x.addr.0.merge
30 ; CHECK-LABEL: polly.start:
31 ; CHECK-NEXT: store i32 %x, ptr %x.addr.0.phiops
34 ; CHECK-LABEL: polly.merge{{[a-z_0-9]*}}:
35 ; CHECK: %x.addr.0.final_reload = load i32, ptr %x.addr.0.s2a
37 for.cond: ; preds = %for.inc5, %entry
38 ; CHECK-LABEL: polly.stmt.for.cond{{[0-9]*}}:
39 ; CHECK: %x.addr.0.phiops.reload[[R1:[0-9]*]] = load i32, ptr %x.addr.0.phiops
40 ; CHECK: store i32 %x.addr.0.phiops.reload[[R1]], ptr %x.addr.0.s2a
41 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc5 ], [ 0, %entry ]
42 %x.addr.0 = phi i32 [ %x, %entry ], [ %x.addr.1, %for.inc5 ]
43 %cmp = icmp slt i64 %indvars.iv, %tmp
44 br i1 %cmp, label %for.body, label %for.end7
46 for.body: ; preds = %for.cond
47 ; CHECK-LABEL: polly.stmt.for.body:
48 ; CHECK: %x.addr.0.s2a.reload[[R2:[0-9]*]] = load i32, ptr %x.addr.0.s2a
49 ; CHECK: store i32 %x.addr.0.s2a.reload[[R2]], ptr %x.addr.1.phiops
52 for.inc5: ; preds = %for.end
53 ; CHECK-LABEL: polly.stmt.for.inc5:
54 ; CHECK: %x.addr.1.s2a.reload[[R5:[0-9]*]] = load i32, ptr %x.addr.1.s2a
55 ; CHECK: store i32 %x.addr.1.s2a.reload[[R5]], ptr %x.addr.0.phiops
56 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 for.cond1: ; preds = %for.inc, %for.body
60 ; CHECK-LABEL: polly.stmt.for.cond1:
61 ; CHECK: %x.addr.1.phiops.reload = load i32, ptr %x.addr.1.phiops
62 ; CHECK: store i32 %x.addr.1.phiops.reload, ptr %x.addr.1.s2a
63 %x.addr.1 = phi i32 [ %x.addr.0, %for.body ], [ %x.addr.2, %for.inc ]
64 %j.0 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
65 %exitcond = icmp ne i32 %j.0, %N
66 br i1 %exitcond, label %for.body3, label %for.end
68 for.body3: ; preds = %for.cond1
69 ; CHECK-LABEL: polly.stmt.for.body3:
70 ; CHECK: %x.addr.1.s2a.reload = load i32, ptr %x.addr.1.s2a
71 ; CHECK: store i32 %x.addr.1.s2a.reload, ptr %x.addr.2.phiops
72 %cmp4 = icmp slt i64 %indvars.iv, %tmp1
73 br i1 %cmp4, label %if.then, label %if.end
75 if.end: ; preds = %if.then, %for.body3
76 ; CHECK-LABEL: polly.stmt.if.end:
77 ; CHECK: %x.addr.2.phiops.reload = load i32, ptr %x.addr.2.phiops
78 ; CHECK: store i32 %x.addr.2.phiops.reload, ptr %x.addr.2.s2a
79 %x.addr.2 = phi i32 [ %add, %if.then ], [ %x.addr.1, %for.body3 ]
82 for.inc: ; preds = %if.end
83 ; CHECK-LABEL: polly.stmt.for.inc:
84 ; CHECK: %x.addr.2.s2a.reload[[R3:[0-9]*]] = load i32, ptr %x.addr.2.s2a
85 ; CHECK: store i32 %x.addr.2.s2a.reload[[R3]], ptr %x.addr.1.phiops
86 %inc = add nsw i32 %j.0, 1
89 if.then: ; preds = %for.body3
90 ; CHECK-LABEL: polly.stmt.if.then:
91 ; CHECK: %x.addr.1.s2a.reload[[R5:[0-9]*]] = load i32, ptr %x.addr.1.s2a
92 ; CHECK: %p_add = add nsw i32 %x.addr.1.s2a.reload[[R5]], %tmp2_p_scalar_
93 ; CHECK: store i32 %p_add, ptr %x.addr.2.phiops
94 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
95 %tmp2 = load i32, ptr %arrayidx, align 4
96 %add = add nsw i32 %x.addr.1, %tmp2
99 for.end: ; preds = %for.cond1
102 for.end7: ; preds = %for.cond