llvm-project
87 строк · 3.4 Кб
1; RUN: opt %loadNPMPolly '-passes=polly-import-jscop,polly-codegen' \
2; RUN: -polly-import-jscop-postfix=transformed \
3; RUN: -verify-dom-info -polly-allow-nonaffine-loops \
4; RUN: -S < %s | FileCheck %s
5
6; This test verifies that partial writes within non-affine loops are code
7; generated correctly.
8
9; CHECK:polly.stmt.bb3:
10; CHECK-NEXT: %polly.subregion.iv = phi i32 [ %polly.subregion.iv.inc, %polly.stmt.bb5.cont ], [ 0, %polly.stmt.bb3.entry ]
11; CHECK-NEXT: %polly.j.0 = phi i64 [ %j.0.phiops.reload, %polly.stmt.bb3.entry ], [ %p_tmp10, %polly.stmt.bb5.cont ]
12; CHECK-NEXT: %8 = zext nneg i64 %polly.indvar to i65
13; CHECK-NEXT: %9 = add nsw i64 %polly.indvar, -1
14; CHECK-NEXT: %10 = zext i64 %9 to i65
15; CHECK-NEXT: %11 = mul i65 %8, %10
16; CHECK-NEXT: %12 = lshr i65 %11, 1
17; CHECK-NEXT: %13 = trunc i65 %12 to i64
18; CHECK-NEXT: %14 = shl i64 %13, 1
19; CHECK-NEXT: %15 = add i64 %polly.indvar, %14
20; CHECK-NEXT: %p_tmp4 = icmp slt i64 %polly.j.0, %15
21; CHECK-NEXT: %polly.subregion.iv.inc = add i32 %polly.subregion.iv, 1
22; CHECK-NEXT: br i1 %p_tmp4, label %polly.stmt.bb5, label %polly.stmt.bb11.exit
23
24; CHECK:polly.stmt.bb5:
25; CHECK-NEXT: %p_tmp6 = getelementptr inbounds float, ptr %B, i64 42
26; CHECK-NEXT: %tmp7_p_scalar_ = load float, ptr %p_tmp6
27; CHECK-NEXT: %p_tmp8 = fadd float %tmp7_p_scalar_, 1.000000e+00
28; CHECK-NEXT: %16 = icmp sle i64 %polly.indvar, 9
29; CHECK-NEXT: %polly.Stmt_bb3__TO__bb11_MayWrite2.cond = icmp ne i1 %16, false
30; CHECK-NEXT: br i1 %polly.Stmt_bb3__TO__bb11_MayWrite2.cond, label %polly.stmt.bb5.Stmt_bb3__TO__bb11_MayWrite2.partial, label %polly.stmt.bb5.cont
31
32; CHECK:polly.stmt.bb5.Stmt_bb3__TO__bb11_MayWrite2.partial: ; preds = %polly.stmt.bb5
33; CHECK-NEXT: %polly.access.B3 = getelementptr float, ptr %B, i64 42
34; CHECK-NEXT: store float %p_tmp8, ptr %polly.access.B3
35; CHECK-NEXT: br label %polly.stmt.bb5.cont
36
37; CHECK:polly.stmt.bb5.cont:
38; CHECK-NEXT: %p_tmp10 = add nuw nsw i64 %polly.j.0, 1
39; CHECK-NEXT: br label %polly.stmt.bb3
40
41
42
43; void foo(long A[], float B[], long *x) {
44; for (long i = 0; i < 1024; i++)
45; for (long j = *x; j < i * i; j++)
46; B[42]++;
47; }
48;
49target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
50
51define void @partial_write_in_region_with_loop(ptr %A, ptr %B, ptr %xptr) {
52bb:
53br label %bb1
54
55bb1: ; preds = %bb12, %bb
56%i.0 = phi i64 [ 0, %bb ], [ %tmp13, %bb12 ]
57%exitcond = icmp ne i64 %i.0, 1024
58br i1 %exitcond, label %bb2, label %bb14
59
60bb2: ; preds = %bb1
61%x = load i64, ptr %xptr
62br label %bb3
63
64bb3: ; preds = %bb9, %bb2
65%j.0 = phi i64 [ %x, %bb2 ], [ %tmp10, %bb5 ]
66%tmp = mul nsw i64 %i.0, %i.0
67%tmp4 = icmp slt i64 %j.0, %tmp
68br i1 %tmp4, label %bb5, label %bb11
69
70bb5: ; preds = %bb3
71%tmp6 = getelementptr inbounds float, ptr %B, i64 42
72%tmp7 = load float, ptr %tmp6, align 4
73%tmp8 = fadd float %tmp7, 1.000000e+00
74store float %tmp8, ptr %tmp6, align 4
75%tmp10 = add nuw nsw i64 %j.0, 1
76br label %bb3
77
78bb11: ; preds = %bb3
79br label %bb12
80
81bb12: ; preds = %bb11
82%tmp13 = add nuw nsw i64 %i.0, 1
83br label %bb1
84
85bb14: ; preds = %bb1
86ret void
87}
88