llvm-project
51 строка · 1.6 Кб
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;
4
5; void f(int a[], int N, float *P, float *Q) {
6; int i;
7; for (i = 0; i < N; ++i)
8; if (P != Q)
9; a[i] = i;
10; }
11;
12target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
13
14define void @f(ptr nocapture %a, i64 %N, ptr %P, ptr %Q) nounwind {
15entry:
16br label %bb
17
18bb:
19%i = phi i64 [ 0, %entry ], [ %i.inc, %bb.backedge ]
20%brcond = icmp ne ptr %P, %Q
21br i1 %brcond, label %store, label %bb.backedge
22
23store:
24%scevgep = getelementptr inbounds i64, ptr %a, i64 %i
25store i64 %i, ptr %scevgep
26br label %bb.backedge
27
28bb.backedge:
29%i.inc = add nsw i64 %i, 1
30%exitcond = icmp eq i64 %i.inc, %N
31br i1 %exitcond, label %return, label %bb
32
33return:
34ret void
35}
36
37; CHECK: if (Q >= P + 1 || P >= Q + 1)
38; CHECK-NEXT: for (int c0 = 0; c0 < N; c0 += 1)
39; CHECK-NEXT: Stmt_store(c0);
40
41; CODEGEN: polly.cond:
42; CODEGEN-NEXT: %[[Q:[_a-zA-Z0-9]+]] = ptrtoint ptr %Q to i64
43; CODEGEN-NEXT: %[[P:[_a-zA-Z0-9]+]] = ptrtoint ptr %P to i64
44; CODEGEN-NEXT: %[[PInc:[_a-zA-Z0-9]+]] = add nsw i64 %[[P]], 1
45; CODEGEN-NEXT: %[[CMP:[_a-zA-Z0-9]+]] = icmp sge i64 %[[Q]], %[[PInc]]
46; CODEGEN-NEXT: %[[P2:[_a-zA-Z0-9]+]] = ptrtoint ptr %P to i64
47; CODEGEN-NEXT: %[[Q2:[_a-zA-Z0-9]+]] = ptrtoint ptr %Q to i64
48; CODEGEN-NEXT: %[[QInc:[_a-zA-Z0-9]+]] = add nsw i64 %[[Q2]], 1
49; CODEGEN-NEXT: %[[CMP2:[_a-zA-Z0-9]+]] = icmp sge i64 %[[P2]], %[[QInc]]
50; CODEGEN-NEXT: %[[CMP3:[_a-zA-Z0-9]+]] = or i1 %[[CMP]], %[[CMP2]]
51; CODEGEN-NEXT: br i1 %[[CMP3]]
52