llvm-project
64 строки · 3.0 Кб
1; RUN: opt %loadNPMPolly -passes=polly-opt-isl -polly-pattern-matching-based-opts=true \
2; RUN: -polly-tc-opt=true -debug -disable-output < %s 2>&1 | FileCheck %s
3; REQUIRES: asserts
4;
5; for (i = 0; i < 32; i++)
6; for (j = 0; j < 1024; j++)
7; for (k = 0; k < 32; ++k)
8; for (l = 0; l < 1024; ++l)
9; C[i][j][k] += A[i][k][l] * B[l][j];
10;
11; CHECK: The tensor contraction pattern was detected
12;
13target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
14target triple = "x86_64-unknown-linux-gnu"
15
16define internal void @kernel_tc(i32 %ni, i32 %nj, i32 %nk, i32 %nl, double %alpha, double %beta, ptr %C, ptr %A, ptr %B) {
17entry:
18br label %for.cond1.preheader
19
20for.cond1.preheader: ; preds = %for.inc30, %entry
21%indvars.iv43 = phi i64 [ 0, %entry ], [ %indvars.iv.next44, %for.inc30 ]
22br label %for.cond4.preheader
23
24for.cond4.preheader: ; preds = %for.inc27, %for.cond1.preheader
25%indvars.iv40 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next41, %for.inc27 ]
26br label %for.cond7.preheader
27
28for.cond7.preheader: ; preds = %for.inc24, %for.cond4.preheader
29%indvars.iv37 = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next38, %for.inc24 ]
30br label %for.body9
31
32for.body9: ; preds = %for.body9, %for.cond7.preheader
33%indvars.iv = phi i64 [ 0, %for.cond7.preheader ], [ %indvars.iv.next, %for.body9 ]
34%arrayidx13 = getelementptr inbounds [32 x [1024 x double]], ptr %A, i64 %indvars.iv43, i64 %indvars.iv37, i64 %indvars.iv
35%i = load double, ptr %arrayidx13, align 8
36%arrayidx17 = getelementptr inbounds [1024 x double], ptr %B, i64 %indvars.iv, i64 %indvars.iv40
37%i1 = load double, ptr %arrayidx17, align 8
38%mul = fmul fast double %i1, %i
39%arrayidx23 = getelementptr inbounds [1024 x [32 x double]], ptr %C, i64 %indvars.iv43, i64 %indvars.iv40, i64 %indvars.iv37
40%i2 = load double, ptr %arrayidx23, align 8
41%add = fadd fast double %i2, %mul
42store double %add, ptr %arrayidx23, align 8
43%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
44%exitcond = icmp ne i64 %indvars.iv.next, 1024
45br i1 %exitcond, label %for.body9, label %for.inc24
46
47for.inc24: ; preds = %for.body9
48%indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
49%exitcond39 = icmp ne i64 %indvars.iv.next38, 32
50br i1 %exitcond39, label %for.cond7.preheader, label %for.inc27
51
52for.inc27: ; preds = %for.inc24
53%indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
54%exitcond42 = icmp ne i64 %indvars.iv.next41, 1024
55br i1 %exitcond42, label %for.cond4.preheader, label %for.inc30
56
57for.inc30: ; preds = %for.inc27
58%indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
59%exitcond45 = icmp ne i64 %indvars.iv.next44, 32
60br i1 %exitcond45, label %for.cond1.preheader, label %for.end32
61
62for.end32: ; preds = %for.inc30
63ret void
64}
65