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