blob: c28a260a21802a216575c4bd8f125835e760060d [file] [log] [blame]
Florian Hahn949294f2020-01-27 16:22:04 -08001; RUN: opt -lower-matrix-intrinsics -pass-remarks=lower-matrix-intrinsics < %s 2>&1 | FileCheck %s
2
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "aarch64-apple-ios"
5
Florian Hahn62e228f2020-01-27 17:17:17 -08006; CHECK-LABEL: remark: test.h:40:20: Lowered with 6 stores, 6 loads, 24 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -08007; CHECK-NEXT: store(
8; CHECK-NEXT: transpose.2x6.double(load(addr %A)),
9; CHECK-NEXT: addr %B)
10define void @transpose(<12 x double>* %A, <12 x double>* %B) !dbg !23 {
11 %load = load <12 x double>, <12 x double>* %A, !dbg !24
12 %t = call <12 x double> @llvm.matrix.transpose.v12f64.v12f64(<12 x double> %load, i32 2, i32 6), !dbg !24
13 store <12 x double> %t, <12 x double>* %B, !dbg !24
14 ret void
15}
16
17declare <12 x double> @llvm.matrix.transpose.v12f64.v12f64(<12 x double>, i32, i32)
18
19
Florian Hahn62e228f2020-01-27 17:17:17 -080020; CHECK-LABEL: remark: test.h:50:20: Lowered with 2 stores, 12 loads, 22 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -080021; CHECK-NEXT: store(
22; CHECK-NEXT: multiply.2x6.6x2.double(
23; CHECK-NEXT: load(addr %A),
24; CHECK-NEXT: load(addr %B)),
25; CHECK-NEXT: addr %C)
26define void @multiply(<12 x double>* %A, <12 x double>* %B, <4 x double>* %C) !dbg !25 {
27 %A.matrix = load <12 x double>, <12 x double>* %A, !dbg !26
28 %B.matrix = load <12 x double>, <12 x double>* %B, !dbg !26
29 %t = call <4 x double> @llvm.matrix.multiply(<12 x double> %A.matrix, <12 x double> %B.matrix, i32 2, i32 6, i32 2), !dbg !26
30 store <4 x double> %t, <4 x double>* %C, !dbg !26
31 ret void
32}
33
34declare <4 x double> @llvm.matrix.multiply(<12 x double>, <12 x double>, i32, i32, i32)
35
Florian Hahn62e228f2020-01-27 17:17:17 -080036; CHECK-LABEL: remark: test.h:60:20: Lowered with 6 stores, 6 loads, 0 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -080037; CHECK-NEXT: store(
38; CHECK-NEXT: columnwise.load.3x3.double(addr %A, 5),
39; CHECK-NEXT: addr %B)
40define void @columnwise.load(<9 x double>* %A, <9 x double>* %B) !dbg !27 {
41 %A.matrix = call <9 x double> @llvm.matrix.columnwise.load(<9 x double>* %A, i32 5, i32 3, i32 3), !dbg !28
42 store <9 x double> %A.matrix, <9 x double>* %B, !dbg !28
43 ret void
44}
45
46declare <9 x double> @llvm.matrix.columnwise.load(<9 x double>*, i32, i32, i32)
47
Florian Hahn62e228f2020-01-27 17:17:17 -080048; CHECK-LABEL: remark: test.h:70:20: Lowered with 6 stores, 6 loads, 0 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -080049; CHECK-NEXT: columnwise.store.3x3.double(
50; CHECK-NEXT: columnwise.load.3x3.double(addr %A, 5),
51; CHECK-NEXT: addr %B,
52; CHECK-NEXT: 10)
53define void @columnwise.store(<9 x double>* %A, <9 x double>* %B) !dbg !29 {
54 %A.matrix = call <9 x double> @llvm.matrix.columnwise.load(<9 x double>* %A, i32 5, i32 3, i32 3), !dbg !30
55 call void @llvm.matrix.columnwise.store(<9 x double> %A.matrix, <9 x double>* %B, i32 10, i32 3, i32 3), !dbg !30
56 ret void
57}
58
59declare void @llvm.matrix.columnwise.store(<9 x double>, <9 x double>*, i32, i32, i32)
60
Florian Hahn62e228f2020-01-27 17:17:17 -080061; CHECK-LABEL: remark: test.h:80:20: Lowered with 6 stores, 6 loads, 12 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -080062; CHECK-NEXT: columnwise.store.3x3.double(
63; CHECK-NEXT: fmul(
64; CHECK-NEXT: fadd(
65; CHECK-NEXT: columnwise.load.3x3.double(addr %A, 5)
66; CHECK-NEXT: (reused) columnwise.load.3x3.double(addr %A, 5)),
67; CHECK-NEXT: (reused) columnwise.load.3x3.double(addr %A, 5)),
68; CHECK-NEXT: addr %B,
69; CHECK-NEXT: 10)
70
71define void @binaryops(<9 x double>* %A, <9 x double>* %B) !dbg !31 {
72 %A.matrix = call <9 x double> @llvm.matrix.columnwise.load(<9 x double>* %A, i32 5, i32 3, i32 3), !dbg !32
73 %R1.matrix = fadd <9 x double> %A.matrix, %A.matrix
74 %R2.matrix = fmul <9 x double> %R1.matrix, %A.matrix
75 call void @llvm.matrix.columnwise.store(<9 x double> %R2.matrix, <9 x double>* %B, i32 10, i32 3, i32 3), !dbg !32
76 ret void
77}
78
Florian Hahn62e228f2020-01-27 17:17:17 -080079; CHECK-LABEL: remark: test.h:90:20: Lowered with 6 stores, 6 loads, 12 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -080080; CHECK-NEXT: columnwise.store.3x3.double(
81; CHECK-NEXT: fmul(
82; CHECK-NEXT: fadd(
83; CHECK-NEXT: columnwise.load.3x3.double(addr %A, 5)
84; CHECK-NEXT: (reused) columnwise.load.3x3.double(addr %A, 5)),
85; CHECK-NEXT: (reused) columnwise.load.3x3.double(addr %A, 5)),
86; CHECK-NEXT: addr %B,
87; CHECK-NEXT: 10)
Florian Hahn62e228f2020-01-27 17:17:17 -080088; CHECK-NEXT: remark: test.h:90:20: Lowered with 2 stores, 12 loads, 22 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -080089; CHECK-NEXT: store(
90; CHECK-NEXT: multiply.2x6.6x2.double(
91; CHECK-NEXT: load(addr %C),
92; CHECK-NEXT: load(addr %D)),
93; CHECK-NEXT: addr %E)
94
95define void @multiple_expressions(<9 x double>* %A, <9 x double>* %B, <12 x double>* %C, <12 x double>* %D, <4 x double>* %E) !dbg !33 {
96 %A.matrix = call <9 x double> @llvm.matrix.columnwise.load(<9 x double>* %A, i32 5, i32 3, i32 3), !dbg !34
97 %R1.matrix = fadd <9 x double> %A.matrix, %A.matrix
98 %R2.matrix = fmul <9 x double> %R1.matrix, %A.matrix
99 call void @llvm.matrix.columnwise.store(<9 x double> %R2.matrix, <9 x double>* %B, i32 10, i32 3, i32 3), !dbg !34
100
101 %C.matrix = load <12 x double>, <12 x double>* %C, !dbg !34
102 %D.matrix = load <12 x double>, <12 x double>* %D, !dbg !34
103 %Mult.matrix = call <4 x double> @llvm.matrix.multiply(<12 x double> %C.matrix, <12 x double> %D.matrix, i32 2, i32 6, i32 2), !dbg !34
104 store <4 x double> %Mult.matrix, <4 x double>* %E, !dbg !34
105
106 ret void
107}
108
Florian Hahn62e228f2020-01-27 17:17:17 -0800109; CHECK-LABEL: remark: test.h:100:20: Lowered with 6 stores, 6 loads, 12 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -0800110; CHECK-NEXT: columnwise.store.3x3.double(
111; CHECK-NEXT: fmul(
112; CHECK-NEXT: fadd(
113; CHECK-NEXT: columnwise.load.3x3.double(addr %A, 5)
114; CHECK-NEXT: (reused) columnwise.load.3x3.double(addr %A, 5)),
115; CHECK-NEXT: (reused) columnwise.load.3x3.double(addr %A, 5)),
116; CHECK-NEXT: stack addr %B,
117; CHECK-NEXT: 10)
118define void @stackaddresses(<9 x double>* %A) !dbg !35 {
119 %B = alloca <9 x double>
120 %A.matrix = call <9 x double> @llvm.matrix.columnwise.load(<9 x double>* %A, i32 5, i32 3, i32 3), !dbg !36
121 %R1.matrix = fadd <9 x double> %A.matrix, %A.matrix
122 %R2.matrix = fmul <9 x double> %R1.matrix, %A.matrix
123 call void @llvm.matrix.columnwise.store(<9 x double> %R2.matrix, <9 x double>* %B, i32 10, i32 3, i32 3), !dbg !36
124 ret void
125}
126
Florian Hahn62e228f2020-01-27 17:17:17 -0800127; CHECK-LABEL: remark: test.h:30:20: Lowered with 10 stores, 9 loads, 30 compute ops
Florian Hahn949294f2020-01-27 16:22:04 -0800128; CHECK-NEXT: store(
129; CHECK-NEXT: transpose.5x3.double(load(addr %A)),
130; CHECK-NEXT: stack addr %s1)
131%S1 = type {<15 x double>*}
132define void @get_underlying_object(%S1* %A) !dbg !21 {
133entry:
134 %s1 = alloca <15 x double>, !dbg !22
135 %a1 = getelementptr %S1, %S1* %A, i32 0, i32 0, !dbg !22
136 %a2 = load <15 x double>*, <15 x double>** %a1, !dbg !22
137 %av = load <15 x double>, <15 x double>* %a2, !dbg !22
138
139 %s2 = bitcast <15 x double>* %s1 to i64*, !dbg !22
140 %s3 = bitcast i64* %s2 to <15 x double>*, !dbg !22
141
142 %t = call <15 x double> @llvm.matrix.transpose.v15f64.v15f64(<15 x double> %av, i32 5, i32 3)
143
144 store <15 x double> %t, <15 x double>* %s3, !dbg !22
145 ret void
146}
147
148declare <15 x double> @llvm.matrix.transpose.v15f64.v15f64(<15 x double>, i32, i32)
149
150!llvm.dbg.cu = !{!0}
151!llvm.module.flags = !{!3, !4}
152
153!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
154!1 = !DIFile(filename: "test.h", directory: "/test")
155!2 = !{}
156!3 = !{i32 2, !"Dwarf Version", i32 4}
157!4 = !{i32 2, !"Debug Info Version", i32 3}
158
159!6 = !DISubroutineType(types: !7)
160!7 = !{null, !8, !8, !11}
161!8 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !9)
162!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, align: 32)
163!10 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
164!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
165!12 = !{!13}
166!13 = !DILocalVariable(name: "a", arg: 1, scope: !5, file: !1, line: 1, type: !8)
167!14 = !DILocation(line: 1, column: 27, scope: !5)
168
169!5 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
170!19 = !DILocation(line: 10, column: 20, scope: !5)
171!20 = !DILocation(line: 10, column: 10, scope: !5)
172
173!21 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
174!22 = !DILocation(line: 30, column: 20, scope: !21)
175
176!23 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
177!24 = !DILocation(line: 40, column: 20, scope: !23)
178
179!25 = distinct !DISubprogram(name: "fn4", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
180!26 = !DILocation(line: 50, column: 20, scope: !25)
181
182!27 = distinct !DISubprogram(name: "fn5", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
183!28 = !DILocation(line: 60, column: 20, scope: !27)
184
185!29 = distinct !DISubprogram(name: "fn6", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
186!30 = !DILocation(line: 70, column: 20, scope: !29)
187
188!31 = distinct !DISubprogram(name: "fn7", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
189!32 = !DILocation(line: 80, column: 20, scope: !31)
190
191!33 = distinct !DISubprogram(name: "fn8", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
192!34 = !DILocation(line: 90, column: 20, scope: !33)
193
194!35 = distinct !DISubprogram(name: "fn9", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
195!36 = !DILocation(line: 100, column: 20, scope: !35)