1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64-unknown-linux \
; RUN: -mattr=-fullfp16 | FileCheck %s --check-prefixes=CHECK,NOFP16
; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64-unknown-linux \
; RUN: -mattr=+fullfp16 | FileCheck %s --check-prefixes=CHECK,FULLFP16
; res = lane 0 * lane 1
define double @extract_case1(<2 x double> %a) {
; CHECK-LABEL: 'extract_case1'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <2 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <2 x double> %a, i32 0
%2 = extractelement <2 x double> %a, i32 1
%res = fmul double %1, %2
ret double %res
}
; res = lane 1 * lane 1
define double @extract_case2(<2 x double> %a) {
; CHECK-LABEL: 'extract_case2'
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %0 = extractelement <2 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %0
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <2 x double> %a, i32 1
%res = fmul double %1, %1
ret double %res
}
; res = lane 0 * lane 0
define double @extract_case3(<2 x double> %a) {
; CHECK-LABEL: 'extract_case3'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %0
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <2 x double> %a, i32 0
%res = fmul double %1, %1
ret double %res
}
; res = lane 0 * scalar
define double @extract_case4(<2 x double> %a, double %b) {
; CHECK-LABEL: 'extract_case4'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %b
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <2 x double> %a, i32 0
%res = fmul double %1, %b
ret double %res
}
; res = lane 1 * scalar
define double @extract_case5(<2 x double> %a, double %b) {
; CHECK-LABEL: 'extract_case5'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %b
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <2 x double> %a, i32 1
%res = fmul double %1, %b
ret double %res
}
; Input vector = <3 x double> (i.e. odd length vector)
; res = lane 0 * lane 1
define double @extract_case6(<3 x double> %a) {
; CHECK-LABEL: 'extract_case6'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <3 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <3 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <3 x double> %a, i32 0
%2 = extractelement <3 x double> %a, i32 1
%res = fmul double %1, %2
ret double %res
}
; res = lane 1 * lane 2
; Extract from lane 2 is equivalent to extract from lane 0 of other 128-bit
; register. But for other register sizes, this is not the case.
define double @extract_case7(<4 x double> %a) {
; CHECK-LABEL: 'extract_case7'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <4 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <4 x double> %a, i32 2
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <4 x double> %a, i32 1
%2 = extractelement <4 x double> %a, i32 2
%res = fmul double %1, %2
ret double %res
}
; res = lane 0 * lane 1
; Additional insert of extract from lane 1.
define double @extract_case8(<2 x double> %a) {
; CHECK-LABEL: 'extract_case8'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %2 = insertelement <2 x double> %a, double %1, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %3 = call double @llvm.vector.reduce.fmul.v2f64(double 0.000000e+00, <2 x double> %2)
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %4 = fmul double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %5 = fmul double %3, %4
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %5
entry:
%1 = extractelement <2 x double> %a, i32 0
%2 = extractelement <2 x double> %a, i32 1
%3 = insertelement <2 x double> %a, double %2, i32 0
%4 = call double @llvm.vector.reduce.fmul.v2f64(double 0.0, <2 x double> %3)
%5 = fmul double %1, %2
%6 = fmul double %4, %5
ret double %6
}
; res = lane 0 * lane 1
; Additional insert of extract from lane 1.
define double @extract_case9(<2 x double> %a) {
; CHECK-LABEL: 'extract_case9'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %2 = insertelement <2 x double> %a, double %1, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %3 = call double @llvm.vector.reduce.fadd.v2f64(double 0.000000e+00, <2 x double> %2)
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %4 = fmul double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %5 = fmul double %3, %4
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %5
entry:
%1 = extractelement <2 x double> %a, i32 0
%2 = extractelement <2 x double> %a, i32 1
%3 = insertelement <2 x double> %a, double %2, i32 0
%4 = call double @llvm.vector.reduce.fadd.v2f64(double 0.0, <2 x double> %3)
%5 = fmul double %1, %2
%6 = fmul double %4, %5
ret double %6
}
; res = lane 0 * lane 1
; Extract from lane 1 passed as function param.
define double @extract_case10(<4 x double> %a) {
; CHECK-LABEL: 'extract_case10'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <4 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <4 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: call void @foo(double %1)
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %2 = fmul double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %2
entry:
%1 = extractelement <4 x double> %a, i32 0
%2 = extractelement <4 x double> %a, i32 1
call void @foo(double %2)
%3 = fmul double %1, %2
ret double %3
}
; res = lane 0 * lane 1
define half @extract_case11(<2 x half> %a) {
; NOFP16-LABEL: 'extract_case11'
; NOFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x half> %a, i32 0
; NOFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x half> %a, i32 1
; NOFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul half %0, %1
; NOFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret half %res
;
; FULLFP16-LABEL: 'extract_case11'
; FULLFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x half> %a, i32 0
; FULLFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <2 x half> %a, i32 1
; FULLFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul half %0, %1
; FULLFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret half %res
entry:
%1 = extractelement <2 x half> %a, i32 0
%2 = extractelement <2 x half> %a, i32 1
%res = fmul half %1, %2
ret half %res
}
; res = lane 0 * lane 1
define float @extract_case12(<2 x float> %a) {
; CHECK-LABEL: 'extract_case12'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x float> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <2 x float> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul float %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %res
entry:
%1 = extractelement <2 x float> %a, i32 0
%2 = extractelement <2 x float> %a, i32 1
%res = fmul float %1, %2
ret float %res
}
; res = lane 0 + lane 1
; Use of bin-op other than fmul.
define double @extract_case13(<2 x double> %a) {
; CHECK-LABEL: 'extract_case13'
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x double> %a, i32 1
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %res = fadd double %0, %1
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res
entry:
%1 = extractelement <2 x double> %a, i32 0
%2 = extractelement <2 x double> %a, i32 1
%res = fadd double %1, %2
ret double %res
}
declare void @foo(double)
|