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
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];
11 ; CHECK: The tensor contraction pattern was detected
13 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-unknown-linux-gnu"
16 define internal void @kernel_tc(i32 %ni, i32 %nj, i32 %nk, i32 %nl, double %alpha, double %beta, ptr %C, ptr %A, ptr %B) {
18 br label %for.cond1.preheader
20 for.cond1.preheader: ; preds = %for.inc30, %entry
21 %indvars.iv43 = phi i64 [ 0, %entry ], [ %indvars.iv.next44, %for.inc30 ]
22 br label %for.cond4.preheader
24 for.cond4.preheader: ; preds = %for.inc27, %for.cond1.preheader
25 %indvars.iv40 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next41, %for.inc27 ]
26 br label %for.cond7.preheader
28 for.cond7.preheader: ; preds = %for.inc24, %for.cond4.preheader
29 %indvars.iv37 = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next38, %for.inc24 ]
32 for.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
42 store 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
45 br i1 %exitcond, label %for.body9, label %for.inc24
47 for.inc24: ; preds = %for.body9
48 %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
49 %exitcond39 = icmp ne i64 %indvars.iv.next38, 32
50 br i1 %exitcond39, label %for.cond7.preheader, label %for.inc27
52 for.inc27: ; preds = %for.inc24
53 %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
54 %exitcond42 = icmp ne i64 %indvars.iv.next41, 1024
55 br i1 %exitcond42, label %for.cond4.preheader, label %for.inc30
57 for.inc30: ; preds = %for.inc27
58 %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
59 %exitcond45 = icmp ne i64 %indvars.iv.next44, 32
60 br i1 %exitcond45, label %for.cond1.preheader, label %for.end32
62 for.end32: ; preds = %for.inc30