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 < 32; j++)
7 ; for (k = 0; k < 32; ++k)
8 ; for (l = 0; l < 32; ++l)
9 ; for (w = 0; w < 32; ++w)
10 ; for (q = 0; q < 32; ++q)
11 ; C[i][j][k][w] += A[i][l][j][q] * B[q][w][l][k];
13 ; CHECK: The tensor contraction pattern was detected
15 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
16 target triple = "x86_64-unknown-linux-gnu"
18 define internal void @kernel_tc(i32 %ni, i32 %nj, i32 %nk, i32 %nl, i32 %nq, i32 %nw, double %alpha, double %beta, ptr %C, ptr %A, ptr %B) {
20 br label %for.cond1.preheader
22 for.cond1.preheader: ; preds = %for.inc50, %entry
23 %indvars.iv71 = phi i64 [ 0, %entry ], [ %indvars.iv.next72, %for.inc50 ]
24 br label %for.cond4.preheader
26 for.cond4.preheader: ; preds = %for.inc47, %for.cond1.preheader
27 %indvars.iv68 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next69, %for.inc47 ]
28 br label %for.cond7.preheader
30 for.cond7.preheader: ; preds = %for.inc44, %for.cond4.preheader
31 %indvars.iv65 = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next66, %for.inc44 ]
32 br label %for.cond10.preheader
34 for.cond10.preheader: ; preds = %for.inc41, %for.cond7.preheader
35 %indvars.iv62 = phi i64 [ 0, %for.cond7.preheader ], [ %indvars.iv.next63, %for.inc41 ]
36 br label %for.cond13.preheader
38 for.cond13.preheader: ; preds = %for.inc38, %for.cond10.preheader
39 %indvars.iv59 = phi i64 [ 0, %for.cond10.preheader ], [ %indvars.iv.next60, %for.inc38 ]
42 for.body15: ; preds = %for.body15, %for.cond13.preheader
43 %indvars.iv = phi i64 [ 0, %for.cond13.preheader ], [ %indvars.iv.next, %for.body15 ]
44 %arrayidx21 = getelementptr inbounds [32 x [32 x [32 x double]]], ptr %A, i64 %indvars.iv71, i64 %indvars.iv62, i64 %indvars.iv68, i64 %indvars.iv
45 %i = load double, ptr %arrayidx21, align 8
46 %arrayidx29 = getelementptr inbounds [32 x [32 x [32 x double]]], ptr %B, i64 %indvars.iv, i64 %indvars.iv59, i64 %indvars.iv62, i64 %indvars.iv65
47 %i1 = load double, ptr %arrayidx29, align 8
48 %mul = fmul fast double %i1, %i
49 %arrayidx37 = getelementptr inbounds [32 x [32 x [32 x double]]], ptr %C, i64 %indvars.iv71, i64 %indvars.iv68, i64 %indvars.iv65, i64 %indvars.iv59
50 %i2 = load double, ptr %arrayidx37, align 8
51 %add = fadd fast double %i2, %mul
52 store double %add, ptr %arrayidx37, align 8
53 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
54 %exitcond = icmp ne i64 %indvars.iv.next, 32
55 br i1 %exitcond, label %for.body15, label %for.inc38
57 for.inc38: ; preds = %for.body15
58 %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
59 %exitcond61 = icmp ne i64 %indvars.iv.next60, 32
60 br i1 %exitcond61, label %for.cond13.preheader, label %for.inc41
62 for.inc41: ; preds = %for.inc38
63 %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
64 %exitcond64 = icmp ne i64 %indvars.iv.next63, 32
65 br i1 %exitcond64, label %for.cond10.preheader, label %for.inc44
67 for.inc44: ; preds = %for.inc41
68 %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
69 %exitcond67 = icmp ne i64 %indvars.iv.next66, 32
70 br i1 %exitcond67, label %for.cond7.preheader, label %for.inc47
72 for.inc47: ; preds = %for.inc44
73 %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
74 %exitcond70 = icmp ne i64 %indvars.iv.next69, 32
75 br i1 %exitcond70, label %for.cond4.preheader, label %for.inc50
77 for.inc50: ; preds = %for.inc47
78 %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
79 %exitcond73 = icmp ne i64 %indvars.iv.next72, 32
80 br i1 %exitcond73, label %for.cond1.preheader, label %for.end52
82 for.end52: ; preds = %for.inc50