1; REQUIRES: aarch64-registered-target 2 3; This test needs to be target specific due to the cost estimate in the output. 4 5; RUN: opt -passes=lower-matrix-intrinsics -pass-remarks=lower-matrix-intrinsics -mtriple=arm64-apple-iphoneos < %s 2>&1 | FileCheck %s 6 7; CHECK-LABEL: remark: test.h:40:20: Lowered with 6 stores, 6 loads, 24 compute ops 8; CHECK-NEXT: store( 9; CHECK-NEXT: transpose.2x6.double(load(addr %A)), 10; CHECK-NEXT: addr %B) 11define void @transpose(ptr %A, ptr %B) !dbg !23 { 12 %load = load <12 x double>, ptr %A, !dbg !24 13 %t = call <12 x double> @llvm.matrix.transpose.v12f64.v12f64(<12 x double> %load, i32 2, i32 6), !dbg !24 14 store <12 x double> %t, ptr %B, !dbg !24 15 ret void 16} 17 18; CHECK-LABEL: remark: test.h:50:20: Lowered with 2 stores, 12 loads, 22 compute ops 19; CHECK-NEXT: store( 20; CHECK-NEXT: multiply.2x6.6x2.double( 21; CHECK-NEXT: load(addr %A), 22; CHECK-NEXT: load(addr %B)), 23; CHECK-NEXT: addr %C) 24define void @multiply(ptr %A, ptr %B, ptr %C) !dbg !25 { 25 %A.matrix = load <12 x double>, ptr %A, !dbg !26 26 %B.matrix = load <12 x double>, ptr %B, !dbg !26 27 %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 28 store <4 x double> %t, ptr %C, !dbg !26 29 ret void 30} 31 32; CHECK-LABEL: remark: test.h:60:20: Lowered with 6 stores, 6 loads, 0 compute ops 33; CHECK-NEXT: store( 34; CHECK-NEXT: column.major.load.3x3.double(addr %A, 5), 35; CHECK-NEXT: addr %B) 36define void @column.major.load(ptr %A, ptr %B) !dbg !27 { 37 %A.matrix = call <9 x double> @llvm.matrix.column.major.load(ptr %A, i64 5, i1 false, i32 3, i32 3), !dbg !28 38 store <9 x double> %A.matrix, ptr %B, !dbg !28 39 ret void 40} 41 42; CHECK-LABEL: remark: test.h:70:20: Lowered with 6 stores, 6 loads, 0 compute ops 43; CHECK-NEXT: column.major.store.3x3.double( 44; CHECK-NEXT: column.major.load.3x3.double(addr %A, 5), 45; CHECK-NEXT: addr %B, 46; CHECK-NEXT: 10) 47define void @column.major.store(ptr %A, ptr %B) !dbg !29 { 48 %A.matrix = call <9 x double> @llvm.matrix.column.major.load(ptr %A, i64 5, i1 false, i32 3, i32 3), !dbg !30 49 call void @llvm.matrix.column.major.store(<9 x double> %A.matrix, ptr %B, i64 10, i1 false, i32 3, i32 3), !dbg !30 50 ret void 51} 52 53; CHECK-LABEL: remark: test.h:80:20: Lowered with 6 stores, 6 loads, 12 compute ops 54; CHECK-NEXT: column.major.store.3x3.double( 55; CHECK-NEXT: fmul( 56; CHECK-NEXT: fadd( 57; CHECK-NEXT: column.major.load.3x3.double(addr %A, 5) 58; CHECK-NEXT: (reused) column.major.load.3x3.double(addr %A, 5)), 59; CHECK-NEXT: (reused) column.major.load.3x3.double(addr %A, 5)), 60; CHECK-NEXT: addr %B, 61; CHECK-NEXT: 10) 62 63define void @binaryops(ptr %A, ptr %B) !dbg !31 { 64 %A.matrix = call <9 x double> @llvm.matrix.column.major.load(ptr %A, i64 5, i1 false, i32 3, i32 3), !dbg !32 65 %R1.matrix = fadd <9 x double> %A.matrix, %A.matrix, !dbg !32 66 %R2.matrix = fmul <9 x double> %R1.matrix, %A.matrix, !dbg !32 67 call void @llvm.matrix.column.major.store(<9 x double> %R2.matrix, ptr %B, i64 10, i1 false, i32 3, i32 3), !dbg !32 68 ret void 69} 70 71; CHECK-LABEL: remark: test.h:90:20: Lowered with 6 stores, 6 loads, 12 compute ops 72; CHECK-NEXT: column.major.store.3x3.double( 73; CHECK-NEXT: fmul( 74; CHECK-NEXT: fadd( 75; CHECK-NEXT: column.major.load.3x3.double(addr %A, 5) 76; CHECK-NEXT: (reused) column.major.load.3x3.double(addr %A, 5)), 77; CHECK-NEXT: (reused) column.major.load.3x3.double(addr %A, 5)), 78; CHECK-NEXT: addr %B, 79; CHECK-NEXT: 10) 80; CHECK-NEXT: remark: test.h:90:20: Lowered with 2 stores, 12 loads, 22 compute ops 81; CHECK-NEXT: store( 82; CHECK-NEXT: multiply.2x6.6x2.double( 83; CHECK-NEXT: load(addr %C), 84; CHECK-NEXT: load(addr %D)), 85; CHECK-NEXT: addr %E) 86 87define void @multiple_expressions(ptr %A, ptr %B, ptr %C, ptr %D, ptr %E) !dbg !33 { 88 %A.matrix = call <9 x double> @llvm.matrix.column.major.load(ptr %A, i64 5, i1 false, i32 3, i32 3), !dbg !34 89 %R1.matrix = fadd <9 x double> %A.matrix, %A.matrix, !dbg !34 90 %R2.matrix = fmul <9 x double> %R1.matrix, %A.matrix, !dbg !34 91 call void @llvm.matrix.column.major.store(<9 x double> %R2.matrix, ptr %B, i64 10, i1 false, i32 3, i32 3), !dbg !34 92 93 %C.matrix = load <12 x double>, ptr %C, !dbg !34 94 %D.matrix = load <12 x double>, ptr %D, !dbg !34 95 %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 96 store <4 x double> %Mult.matrix, ptr %E, !dbg !34 97 98 ret void 99} 100 101; CHECK-LABEL: remark: test.h:100:20: Lowered with 6 stores, 6 loads, 12 compute ops 102; CHECK-NEXT: column.major.store.3x3.double( 103; CHECK-NEXT: fmul( 104; CHECK-NEXT: fadd( 105; CHECK-NEXT: column.major.load.3x3.double(addr %A, 5) 106; CHECK-NEXT: (reused) column.major.load.3x3.double(addr %A, 5)), 107; CHECK-NEXT: (reused) column.major.load.3x3.double(addr %A, 5)), 108; CHECK-NEXT: addr %B, 109; CHECK-NEXT: 10) 110define void @stackaddresses(ptr %A, ptr %B) !dbg !35 { 111 %A.matrix = call <9 x double> @llvm.matrix.column.major.load(ptr %A, i64 5, i1 false, i32 3, i32 3), !dbg !36 112 %R1.matrix = fadd <9 x double> %A.matrix, %A.matrix, !dbg !36 113 %R2.matrix = fmul <9 x double> %R1.matrix, %A.matrix, !dbg !36 114 call void @llvm.matrix.column.major.store(<9 x double> %R2.matrix, ptr %B, i64 10, i1 false, i32 3, i32 3), !dbg !36 115 ret void 116} 117 118; CHECK-LABEL: remark: test.h:30:20: Lowered with 10 stores, 9 loads, 30 compute ops 119; CHECK-NEXT: store( 120; CHECK-NEXT: transpose.5x3.double(load(addr %A)), 121; CHECK-NEXT: stack addr %s1) 122%S1 = type {ptr} 123define void @get_underlying_object(ptr %A) !dbg !21 { 124entry: 125 %s1 = alloca <15 x double>, !dbg !22 126 %a2 = load ptr, ptr %A, !dbg !22 127 %av = load <15 x double>, ptr %a2, !dbg !22 128 129 130 %t = call <15 x double> @llvm.matrix.transpose.v15f64.v15f64(<15 x double> %av, i32 5, i32 3), !dbg !22 131 132 store <15 x double> %t, ptr %s1, !dbg !22 133 ret void 134} 135 136declare <12 x double> @llvm.matrix.transpose.v12f64.v12f64(<12 x double>, i32, i32) 137declare <4 x double> @llvm.matrix.multiply(<12 x double>, <12 x double>, i32, i32, i32) 138declare <9 x double> @llvm.matrix.column.major.load(ptr, i64, i1, i32, i32) 139declare <15 x double> @llvm.matrix.transpose.v15f64.v15f64(<15 x double>, i32, i32) 140declare void @llvm.matrix.column.major.store(<9 x double>, ptr, i64, i1, i32, i32) 141 142 143!llvm.dbg.cu = !{!0} 144!llvm.module.flags = !{!3, !4} 145 146!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 147!1 = !DIFile(filename: "test.h", directory: "/test") 148!2 = !{} 149!3 = !{i32 2, !"Dwarf Version", i32 4} 150!4 = !{i32 2, !"Debug Info Version", i32 3} 151 152!6 = !DISubroutineType(types: !7) 153!7 = !{null, !8, !8, !11} 154!8 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !9) 155!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, align: 32) 156!10 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float) 157!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 158!12 = !{!13} 159!13 = !DILocalVariable(name: "a", arg: 1, scope: !5, file: !1, line: 1, type: !8) 160!14 = !DILocation(line: 1, column: 27, scope: !5) 161 162!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) 163!19 = !DILocation(line: 10, column: 20, scope: !5) 164!20 = !DILocation(line: 10, column: 10, scope: !5) 165 166!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) 167!22 = !DILocation(line: 30, column: 20, scope: !21) 168 169!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) 170!24 = !DILocation(line: 40, column: 20, scope: !23) 171 172!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) 173!26 = !DILocation(line: 50, column: 20, scope: !25) 174 175!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) 176!28 = !DILocation(line: 60, column: 20, scope: !27) 177 178!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) 179!30 = !DILocation(line: 70, column: 20, scope: !29) 180 181!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) 182!32 = !DILocation(line: 80, column: 20, scope: !31) 183 184!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) 185!34 = !DILocation(line: 90, column: 20, scope: !33) 186 187!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) 188!36 = !DILocation(line: 100, column: 20, scope: !35) 189