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 < 16; i++)
6 ; for (j = 0; j < 16; j++)
7 ; for (k = 0; k < 8; ++k)
8 ; for (l = 0; l < 1024; ++l)
9 ; for (w = 0; w < 8; ++w)
10 ; for (q = 0; q < 8; ++q)
11 ; for (x = 0; x < 8; ++x)
12 ; C[i][j][k][w][q][x] += A[l][x][j][k] * B[w][q][l][i];
14 ; CHECK: The tensor contraction pattern was detected
16 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-unknown-linux-gnu"
19 define internal void @kernel_tc(ptr %C, ptr %A, ptr %B) {
21 br label %for.cond1.preheader
23 for.cond1.preheader: ; preds = %for.inc60, %entry
24 %indvars.iv85 = phi i64 [ 0, %entry ], [ %indvars.iv.next86, %for.inc60 ]
25 br label %for.cond4.preheader
27 for.cond4.preheader: ; preds = %for.inc57, %for.cond1.preheader
28 %indvars.iv82 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next83, %for.inc57 ]
29 br label %for.cond7.preheader
31 for.cond7.preheader: ; preds = %for.inc54, %for.cond4.preheader
32 %indvars.iv79 = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next80, %for.inc54 ]
33 br label %for.cond10.preheader
35 for.cond10.preheader: ; preds = %for.inc51, %for.cond7.preheader
36 %indvars.iv76 = phi i64 [ 0, %for.cond7.preheader ], [ %indvars.iv.next77, %for.inc51 ]
37 br label %for.cond13.preheader
39 for.cond13.preheader: ; preds = %for.inc48, %for.cond10.preheader
40 %indvars.iv73 = phi i64 [ 0, %for.cond10.preheader ], [ %indvars.iv.next74, %for.inc48 ]
41 br label %for.cond16.preheader
43 for.cond16.preheader: ; preds = %for.inc45, %for.cond13.preheader
44 %indvars.iv70 = phi i64 [ 0, %for.cond13.preheader ], [ %indvars.iv.next71, %for.inc45 ]
47 for.body18: ; preds = %for.body18, %for.cond16.preheader
48 %indvars.iv = phi i64 [ 0, %for.cond16.preheader ], [ %indvars.iv.next, %for.body18 ]
49 %arrayidx24 = getelementptr inbounds [8 x [16 x [8 x double]]], ptr %A, i64 %indvars.iv76, i64 %indvars.iv, i64 %indvars.iv82, i64 %indvars.iv79
50 %i = load double, ptr %arrayidx24, align 8
51 %arrayidx32 = getelementptr inbounds [8 x [1024 x [16 x double]]], ptr %B, i64 %indvars.iv73, i64 %indvars.iv70, i64 %indvars.iv76, i64 %indvars.iv85
52 %i1 = load double, ptr %arrayidx32, align 8
53 %mul = fmul fast double %i1, %i
54 %arrayidx44 = getelementptr inbounds [16 x [8 x [8 x [8 x [8 x double]]]]], ptr %C, i64 %indvars.iv85, i64 %indvars.iv82, i64 %indvars.iv79, i64 %indvars.iv73, i64 %indvars.iv70, i64 %indvars.iv
55 %i2 = load double, ptr %arrayidx44, align 8
56 %add = fadd fast double %i2, %mul
57 store double %add, ptr %arrayidx44, align 8
58 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 %exitcond = icmp ne i64 %indvars.iv.next, 8
60 br i1 %exitcond, label %for.body18, label %for.inc45
62 for.inc45: ; preds = %for.body18
63 %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
64 %exitcond72 = icmp ne i64 %indvars.iv.next71, 8
65 br i1 %exitcond72, label %for.cond16.preheader, label %for.inc48
67 for.inc48: ; preds = %for.inc45
68 %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
69 %exitcond75 = icmp ne i64 %indvars.iv.next74, 8
70 br i1 %exitcond75, label %for.cond13.preheader, label %for.inc51
72 for.inc51: ; preds = %for.inc48
73 %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
74 %exitcond78 = icmp ne i64 %indvars.iv.next77, 1024
75 br i1 %exitcond78, label %for.cond10.preheader, label %for.inc54
77 for.inc54: ; preds = %for.inc51
78 %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
79 %exitcond81 = icmp ne i64 %indvars.iv.next80, 8
80 br i1 %exitcond81, label %for.cond7.preheader, label %for.inc57
82 for.inc57: ; preds = %for.inc54
83 %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
84 %exitcond84 = icmp ne i64 %indvars.iv.next83, 16
85 br i1 %exitcond84, label %for.cond4.preheader, label %for.inc60
87 for.inc60: ; preds = %for.inc57
88 %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
89 %exitcond87 = icmp ne i64 %indvars.iv.next86, 16
90 br i1 %exitcond87, label %for.cond1.preheader, label %for.end62
92 for.end62: ; preds = %for.inc60