1 ; RUN: opt %loadPolly -polly-delicm -polly-simplify -polly-opt-isl \
2 ; RUN: -polly-pattern-matching-based-opts=true \
3 ; RUN: -polly-tc-opt=true -debug -disable-output < %s 2>&1 | FileCheck %s
6 ; Check that the pattern matching detects the tensor contraction pattern
7 ; after a full run of -polly-delicm. This test case generates the following
8 ; schedule, which contans two band nodes. Without DeLICM two statement are
11 ; domain: "{ Stmt5[i0, i1, i2, i3, i4, i5] : 0 <= i0 <= 31 and 0 <= i1 <= 31 and
12 ; 0 <= i2 <= 31 and 0 <= i3 <= 31 and
13 ; 0 <= i4 <= 31 and 0 <= i5 <= 31 }"
15 ; schedule: "[{ Stmt5[i0, i1, i2, i3, i4, i5] -> [(i0)] },
16 ; { Stmt5[i0, i1, i2, i3, i4, i5] -> [(i1)] },
17 ; { Stmt5[i0, i1, i2, i3, i4, i5] -> [(i2)] },
18 ; { Stmt5[i0, i1, i2, i3, i4, i5] -> [(i4)] },
19 ; { Stmt5[i0, i1, i2, i3, i4, i5] -> [(i3)] }]"
21 ; coincident: [ 1, 1, 1, 1, 0 ]
23 ; schedule: "[{ Stmt5[i0, i1, i2, i3, i4, i5] -> [(i5)] }]"
28 ; for (i = 0; i < 32; i++)
29 ; for (j = 0; j < 32; j++)
30 ; for (k = 0; k < 32; ++k)
31 ; for (l = 0; l < 32; ++l)
32 ; for (w = 0; w < 32; ++w)
33 ; for (q = 0; q < 32; ++q)
34 ; C[i][j][k][w] += A[i][l][j][q] * B[q][w][l][k];
36 ; CHECK: The tensor contraction pattern was detected
38 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "x86_64-unknown-linux-gnu"
41 define internal fastcc void @kernel_tc(ptr nocapture %C, ptr nocapture readonly %A, ptr nocapture readonly %B) {
43 br label %for.cond1.preheader
45 for.cond1.preheader: ; preds = %for.inc50, %entry
46 %indvars.iv19 = phi i64 [ 0, %entry ], [ %indvars.iv.next20, %for.inc50 ]
47 br label %for.cond4.preheader
49 for.cond4.preheader: ; preds = %for.inc47, %for.cond1.preheader
50 %indvars.iv16 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next17, %for.inc47 ]
51 br label %for.cond7.preheader
53 for.cond7.preheader: ; preds = %for.inc44, %for.cond4.preheader
54 %indvars.iv13 = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next14, %for.inc44 ]
55 br label %for.cond10.preheader
57 for.cond10.preheader: ; preds = %for.inc41, %for.cond7.preheader
58 %indvars.iv10 = phi i64 [ 0, %for.cond7.preheader ], [ %indvars.iv.next11, %for.inc41 ]
59 br label %for.cond13.preheader
61 for.cond13.preheader: ; preds = %for.inc38, %for.cond10.preheader
62 %indvars.iv7 = phi i64 [ 0, %for.cond10.preheader ], [ %indvars.iv.next8, %for.inc38 ]
63 %arrayidx37 = getelementptr inbounds [32 x [32 x [32 x double]]], ptr %C, i64 %indvars.iv19, i64 %indvars.iv16, i64 %indvars.iv13, i64 %indvars.iv7
64 %.pre = load double, ptr %arrayidx37, align 8
67 for.body15: ; preds = %for.body15, %for.cond13.preheader
68 %i = phi double [ %.pre, %for.cond13.preheader ], [ %add, %for.body15 ]
69 %indvars.iv = phi i64 [ 0, %for.cond13.preheader ], [ %indvars.iv.next, %for.body15 ]
70 %arrayidx21 = getelementptr inbounds [32 x [32 x [32 x double]]], ptr %A, i64 %indvars.iv19, i64 %indvars.iv10, i64 %indvars.iv16, i64 %indvars.iv
71 %i1 = load double, ptr %arrayidx21, align 8
72 %arrayidx29 = getelementptr inbounds [32 x [32 x [32 x double]]], ptr %B, i64 %indvars.iv, i64 %indvars.iv7, i64 %indvars.iv10, i64 %indvars.iv13
73 %i2 = load double, ptr %arrayidx29, align 8
74 %mul = fmul fast double %i2, %i1
75 %add = fadd fast double %i, %mul
76 store double %add, ptr %arrayidx37, align 8
77 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
78 %exitcond.not = icmp eq i64 %indvars.iv.next, 32
79 br i1 %exitcond.not, label %for.inc38, label %for.body15
81 for.inc38: ; preds = %for.body15
82 %indvars.iv.next8 = add nuw nsw i64 %indvars.iv7, 1
83 %exitcond9.not = icmp eq i64 %indvars.iv.next8, 32
84 br i1 %exitcond9.not, label %for.inc41, label %for.cond13.preheader
86 for.inc41: ; preds = %for.inc38
87 %indvars.iv.next11 = add nuw nsw i64 %indvars.iv10, 1
88 %exitcond12.not = icmp eq i64 %indvars.iv.next11, 32
89 br i1 %exitcond12.not, label %for.inc44, label %for.cond10.preheader
91 for.inc44: ; preds = %for.inc41
92 %indvars.iv.next14 = add nuw nsw i64 %indvars.iv13, 1
93 %exitcond15.not = icmp eq i64 %indvars.iv.next14, 32
94 br i1 %exitcond15.not, label %for.inc47, label %for.cond7.preheader
96 for.inc47: ; preds = %for.inc44
97 %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1
98 %exitcond18.not = icmp eq i64 %indvars.iv.next17, 32
99 br i1 %exitcond18.not, label %for.inc50, label %for.cond4.preheader
101 for.inc50: ; preds = %for.inc47
102 %indvars.iv.next20 = add nuw nsw i64 %indvars.iv19, 1
103 %exitcond21.not = icmp eq i64 %indvars.iv.next20, 32
104 br i1 %exitcond21.not, label %for.end52, label %for.cond1.preheader
106 for.end52: ; preds = %for.inc50