llvm-project
108 строк · 5.2 Кб
1; RUN: opt %loadNPMPolly '-passes=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
4; REQUIRES: asserts
5;
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
9; generated.
10;
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 }"
14; child:
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)] }]"
20; permutable: 1
21; coincident: [ 1, 1, 1, 1, 0 ]
22; child:
23; schedule: "[{ Stmt5[i0, i1, i2, i3, i4, i5] -> [(i5)] }]"
24; permutable: 1
25; child:
26; leaf
27;
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];
35;
36; CHECK: The tensor contraction pattern was detected
37;
38target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
39target triple = "x86_64-unknown-linux-gnu"
40
41define internal fastcc void @kernel_tc(ptr nocapture %C, ptr nocapture readonly %A, ptr nocapture readonly %B) {
42entry:
43br label %for.cond1.preheader
44
45for.cond1.preheader: ; preds = %for.inc50, %entry
46%indvars.iv19 = phi i64 [ 0, %entry ], [ %indvars.iv.next20, %for.inc50 ]
47br label %for.cond4.preheader
48
49for.cond4.preheader: ; preds = %for.inc47, %for.cond1.preheader
50%indvars.iv16 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next17, %for.inc47 ]
51br label %for.cond7.preheader
52
53for.cond7.preheader: ; preds = %for.inc44, %for.cond4.preheader
54%indvars.iv13 = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next14, %for.inc44 ]
55br label %for.cond10.preheader
56
57for.cond10.preheader: ; preds = %for.inc41, %for.cond7.preheader
58%indvars.iv10 = phi i64 [ 0, %for.cond7.preheader ], [ %indvars.iv.next11, %for.inc41 ]
59br label %for.cond13.preheader
60
61for.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
65br label %for.body15
66
67for.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
76store 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
79br i1 %exitcond.not, label %for.inc38, label %for.body15
80
81for.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
84br i1 %exitcond9.not, label %for.inc41, label %for.cond13.preheader
85
86for.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
89br i1 %exitcond12.not, label %for.inc44, label %for.cond10.preheader
90
91for.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
94br i1 %exitcond15.not, label %for.inc47, label %for.cond7.preheader
95
96for.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
99br i1 %exitcond18.not, label %for.inc50, label %for.cond4.preheader
100
101for.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
104br i1 %exitcond21.not, label %for.end52, label %for.cond1.preheader
105
106for.end52: ; preds = %for.inc50
107ret void
108}
109