1 ; RUN: opt %loadNPMPolly -polly-pattern-matching-based-opts=true \
2 ; RUN: -polly-target-throughput-vector-fma=1 \
3 ; RUN: -polly-target-latency-vector-fma=8 \
4 ; RUN: -polly-target-1st-cache-level-associativity=8 \
5 ; RUN: -polly-target-2nd-cache-level-associativity=8 \
6 ; RUN: -polly-target-1st-cache-level-size=32768 \
7 ; RUN: -polly-target-vector-register-bitwidth=256 \
8 ; RUN: -polly-target-2nd-cache-level-size=262144 \
9 ; RUN: '-passes=polly-opt-isl,print<polly-ast>' -disable-output < %s | FileCheck %s
11 ; /* C := A * B + C */
12 ; /* Elements of the matrices A, B, C have the float type. */
13 ; /* The type size of elements of the matrix multiplication operands is used
14 ; to determine the parameters of the code produced by the optimization
15 ; of the matrix multiplication (e.g. bounds of the loops of the loop
16 ; nest, the innermost loop body). This test checks the form of
17 ; the generated loop nest. See getMicroKernelParams and
18 ; getMacroKernelParams from lib/Transform/ScheduleOptimizer.cpp
20 ; for (i = 0; i < _PB_NI; i++)
21 ; for (j = 0; j < _PB_NJ; j++)
22 ; for (k = 0; k < _PB_NK; ++k)
23 ; C[i][j] += A[i][k] * B[k][j];
25 ; CHECK: // 1st level tiling - Tiles
26 ; CHECK-NEXT: for (int c1 = 0; c1 <= 2; c1 += 1) {
27 ; CHECK-NEXT: for (int c3 = 0; c3 <= 1023; c3 += 1)
28 ; CHECK-NEXT: for (int c4 = 384 * c1; c4 <= min(1023, 384 * c1 + 383); c4 += 1)
29 ; CHECK-NEXT: CopyStmt_0(0, c3, c4);
30 ; CHECK-NEXT: for (int c2 = 0; c2 <= 7; c2 += 1) {
31 ; CHECK-NEXT: for (int c6 = 128 * c2; c6 <= 128 * c2 + 127; c6 += 1)
32 ; CHECK-NEXT: for (int c7 = 384 * c1; c7 <= min(1023, 384 * c1 + 383); c7 += 1)
33 ; CHECK-NEXT: CopyStmt_1(0, c1, c2, c6, c7);
34 ; CHECK-NEXT: // 1st level tiling - Points
35 ; CHECK-NEXT: // Register tiling - Tiles
36 ; CHECK-NEXT: for (int c3 = 0; c3 <= 127; c3 += 1)
37 ; CHECK-NEXT: for (int c4 = 0; c4 <= 15; c4 += 1)
38 ; CHECK-NEXT: for (int c5 = 0; c5 <= min(383, -384 * c1 + 1023); c5 += 1) {
39 ; CHECK-NEXT: // Loop Vectorizer Disabled
40 ; CHECK-NEXT: // Register tiling - Points
42 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3, 384 * c1 + c5);
43 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 1, 384 * c1 + c5);
44 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 2, 384 * c1 + c5);
45 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 3, 384 * c1 + c5);
46 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 4, 384 * c1 + c5);
47 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 5, 384 * c1 + c5);
48 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 6, 384 * c1 + c5);
49 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4, 8 * c3 + 7, 384 * c1 + c5);
50 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3, 384 * c1 + c5);
51 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 1, 384 * c1 + c5);
52 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 2, 384 * c1 + c5);
53 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 3, 384 * c1 + c5);
54 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 4, 384 * c1 + c5);
55 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 5, 384 * c1 + c5);
56 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 6, 384 * c1 + c5);
57 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 1, 8 * c3 + 7, 384 * c1 + c5);
58 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3, 384 * c1 + c5);
59 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 1, 384 * c1 + c5);
60 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 2, 384 * c1 + c5);
61 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 3, 384 * c1 + c5);
62 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 4, 384 * c1 + c5);
63 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 5, 384 * c1 + c5);
64 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 6, 384 * c1 + c5);
65 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 2, 8 * c3 + 7, 384 * c1 + c5);
66 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3, 384 * c1 + c5);
67 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 1, 384 * c1 + c5);
68 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 2, 384 * c1 + c5);
69 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 3, 384 * c1 + c5);
70 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 4, 384 * c1 + c5);
71 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 5, 384 * c1 + c5);
72 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 6, 384 * c1 + c5);
73 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 3, 8 * c3 + 7, 384 * c1 + c5);
74 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3, 384 * c1 + c5);
75 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 1, 384 * c1 + c5);
76 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 2, 384 * c1 + c5);
77 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 3, 384 * c1 + c5);
78 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 4, 384 * c1 + c5);
79 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 5, 384 * c1 + c5);
80 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 6, 384 * c1 + c5);
81 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 4, 8 * c3 + 7, 384 * c1 + c5);
82 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3, 384 * c1 + c5);
83 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 1, 384 * c1 + c5);
84 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 2, 384 * c1 + c5);
85 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 3, 384 * c1 + c5);
86 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 4, 384 * c1 + c5);
87 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 5, 384 * c1 + c5);
88 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 6, 384 * c1 + c5);
89 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 5, 8 * c3 + 7, 384 * c1 + c5);
90 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3, 384 * c1 + c5);
91 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 1, 384 * c1 + c5);
92 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 2, 384 * c1 + c5);
93 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 3, 384 * c1 + c5);
94 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 4, 384 * c1 + c5);
95 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 5, 384 * c1 + c5);
96 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 6, 384 * c1 + c5);
97 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 6, 8 * c3 + 7, 384 * c1 + c5);
98 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3, 384 * c1 + c5);
99 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 1, 384 * c1 + c5);
100 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 2, 384 * c1 + c5);
101 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 3, 384 * c1 + c5);
102 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 4, 384 * c1 + c5);
103 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 5, 384 * c1 + c5);
104 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 6, 384 * c1 + c5);
105 ; CHECK-NEXT: Stmt_for_body6(128 * c2 + 8 * c4 + 7, 8 * c3 + 7, 384 * c1 + c5);
111 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
112 target triple = "x86_64-unknown-unknown"
114 ; Function Attrs: noinline nounwind uwtable
115 define internal void @kernel_gemm(i32 %ni, i32 %nj, i32 %nk, float %alpha, float %beta, ptr %C, ptr %A, ptr %B) #0 {
117 br label %entry.split
119 entry.split: ; preds = %entry
120 br label %for.cond1.preheader
122 for.cond1.preheader: ; preds = %for.inc20, %entry.split
123 %indvars.iv41 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next42, %for.inc20 ]
124 br label %for.cond4.preheader
126 for.cond4.preheader: ; preds = %for.inc17, %for.cond1.preheader
127 %indvars.iv38 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next39, %for.inc17 ]
130 for.body6: ; preds = %for.body6, %for.cond4.preheader
131 %indvars.iv = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next, %for.body6 ]
132 %arrayidx8 = getelementptr inbounds [1024 x float], ptr %A, i64 %indvars.iv41, i64 %indvars.iv
133 %tmp = load float, ptr %arrayidx8, align 4
134 %arrayidx12 = getelementptr inbounds [1024 x float], ptr %B, i64 %indvars.iv, i64 %indvars.iv38
135 %tmp1 = load float, ptr %arrayidx12, align 4
136 %mul = fmul float %tmp, %tmp1
137 %arrayidx16 = getelementptr inbounds [1024 x float], ptr %C, i64 %indvars.iv41, i64 %indvars.iv38
138 %tmp2 = load float, ptr %arrayidx16, align 4
139 %add = fadd float %tmp2, %mul
140 store float %add, ptr %arrayidx16, align 4
141 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
142 %exitcond = icmp ne i64 %indvars.iv.next, 1024
143 br i1 %exitcond, label %for.body6, label %for.inc17
145 for.inc17: ; preds = %for.body6
146 %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
147 %exitcond40 = icmp ne i64 %indvars.iv.next39, 1024
148 br i1 %exitcond40, label %for.cond4.preheader, label %for.inc20
150 for.inc20: ; preds = %for.inc17
151 %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
152 %exitcond43 = icmp ne i64 %indvars.iv.next42, 1024
153 br i1 %exitcond43, label %for.cond1.preheader, label %for.end22
155 for.end22: ; preds = %for.inc20