llvm-project
43 строки · 1.5 Кб
1; RUN: opt %loadNPMPolly '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s
2;
3; void jd(int *A, int *B, int c) {
4; for (int i = 0; i < 1024; i++)
5; A[i] = B[c - 10] + B[5];
6; }
7;
8; CHECK: if (1 && 0 == c <= -{{[0-9]*}} && (&MemRef_B[max(6, c - 9)] <= &MemRef_A[0] || &MemRef_A[1024] <= &MemRef_B[min(5, c - 10)]))
9; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1)
10; CHECK: Stmt_for_body(c0);
11; CHECK: else
12; CHECK: /* original code */
13;
14target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
15
16define void @jd(ptr %A, ptr %B, i32 %c) {
17entry:
18br label %for.cond
19
20for.cond: ; preds = %for.inc, %entry
21%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
22%exitcond = icmp ne i64 %indvars.iv, 1024
23br i1 %exitcond, label %for.body, label %for.end
24
25for.body: ; preds = %for.cond
26%sub = add nsw i32 %c, -10
27%idxprom = sext i32 %sub to i64
28%arrayidx = getelementptr inbounds i32, ptr %B, i64 %idxprom
29%tmp = load i32, ptr %arrayidx, align 4
30%arrayidx1 = getelementptr inbounds i32, ptr %B, i64 5
31%tmp1 = load i32, ptr %arrayidx1, align 4
32%add = add nsw i32 %tmp, %tmp1
33%arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
34store i32 %add, ptr %arrayidx3, align 4
35br label %for.inc
36
37for.inc: ; preds = %for.body
38%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
39br label %for.cond
40
41for.end: ; preds = %for.cond
42ret void
43}
44