222 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 52; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64-unknown-linux \3; RUN: -mattr=-fullfp16 | FileCheck %s --check-prefixes=CHECK,NOFP164; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64-unknown-linux \5; RUN: -mattr=+fullfp16 | FileCheck %s --check-prefixes=CHECK,FULLFP166 7; res = lane 0 * lane 18define double @extract_case1(<2 x double> %a) {9; CHECK-LABEL: 'extract_case1'10; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 011; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <2 x double> %a, i32 112; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %113; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res14;15entry:16 %1 = extractelement <2 x double> %a, i32 017 %2 = extractelement <2 x double> %a, i32 118 %res = fmul double %1, %219 ret double %res20}21 22; res = lane 1 * lane 123define double @extract_case2(<2 x double> %a) {24; CHECK-LABEL: 'extract_case2'25; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %0 = extractelement <2 x double> %a, i32 126; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %027; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res28;29entry:30 %1 = extractelement <2 x double> %a, i32 131 %res = fmul double %1, %132 ret double %res33}34 35; res = lane 0 * lane 036define double @extract_case3(<2 x double> %a) {37; CHECK-LABEL: 'extract_case3'38; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 039; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %040; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res41;42entry:43 %1 = extractelement <2 x double> %a, i32 044 %res = fmul double %1, %145 ret double %res46}47 48; res = lane 0 * scalar49define double @extract_case4(<2 x double> %a, double %b) {50; CHECK-LABEL: 'extract_case4'51; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 052; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %b53; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res54;55entry:56 %1 = extractelement <2 x double> %a, i32 057 %res = fmul double %1, %b58 ret double %res59}60 61; res = lane 1 * scalar62define double @extract_case5(<2 x double> %a, double %b) {63; CHECK-LABEL: 'extract_case5'64; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 165; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %b66; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res67;68entry:69 %1 = extractelement <2 x double> %a, i32 170 %res = fmul double %1, %b71 ret double %res72}73 74; Input vector = <3 x double> (i.e. odd length vector)75; res = lane 0 * lane 176define double @extract_case6(<3 x double> %a) {77; CHECK-LABEL: 'extract_case6'78; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <3 x double> %a, i32 079; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <3 x double> %a, i32 180; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %181; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res82;83entry:84 %1 = extractelement <3 x double> %a, i32 085 %2 = extractelement <3 x double> %a, i32 186 %res = fmul double %1, %287 ret double %res88}89 90; res = lane 1 * lane 291; Extract from lane 2 is equivalent to extract from lane 0 of other 128-bit92; register. But for other register sizes, this is not the case.93define double @extract_case7(<4 x double> %a) {94; CHECK-LABEL: 'extract_case7'95; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <4 x double> %a, i32 196; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <4 x double> %a, i32 297; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul double %0, %198; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res99;100entry:101 %1 = extractelement <4 x double> %a, i32 1102 %2 = extractelement <4 x double> %a, i32 2103 %res = fmul double %1, %2104 ret double %res105}106 107; res = lane 0 * lane 1108; Additional insert of extract from lane 1.109define double @extract_case8(<2 x double> %a) {110; CHECK-LABEL: 'extract_case8'111; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0112; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x double> %a, i32 1113; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %2 = insertelement <2 x double> %a, double %1, i32 0114; 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)115; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %4 = fmul double %0, %1116; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %5 = fmul double %3, %4117; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %5118;119entry:120 %1 = extractelement <2 x double> %a, i32 0121 %2 = extractelement <2 x double> %a, i32 1122 %3 = insertelement <2 x double> %a, double %2, i32 0123 %4 = call double @llvm.vector.reduce.fmul.v2f64(double 0.0, <2 x double> %3)124 %5 = fmul double %1, %2125 %6 = fmul double %4, %5126 ret double %6127}128 129; res = lane 0 * lane 1130; Additional insert of extract from lane 1.131define double @extract_case9(<2 x double> %a) {132; CHECK-LABEL: 'extract_case9'133; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0134; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x double> %a, i32 1135; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %2 = insertelement <2 x double> %a, double %1, i32 0136; 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)137; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %4 = fmul double %0, %1138; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %5 = fmul double %3, %4139; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %5140;141entry:142 %1 = extractelement <2 x double> %a, i32 0143 %2 = extractelement <2 x double> %a, i32 1144 %3 = insertelement <2 x double> %a, double %2, i32 0145 %4 = call double @llvm.vector.reduce.fadd.v2f64(double 0.0, <2 x double> %3)146 %5 = fmul double %1, %2147 %6 = fmul double %4, %5148 ret double %6149}150 151; res = lane 0 * lane 1152; Extract from lane 1 passed as function param.153define double @extract_case10(<4 x double> %a) {154; CHECK-LABEL: 'extract_case10'155; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <4 x double> %a, i32 0156; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <4 x double> %a, i32 1157; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: call void @foo(double %1)158; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %2 = fmul double %0, %1159; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %2160;161entry:162 %1 = extractelement <4 x double> %a, i32 0163 %2 = extractelement <4 x double> %a, i32 1164 call void @foo(double %2)165 %3 = fmul double %1, %2166 ret double %3167}168 169; res = lane 0 * lane 1170define half @extract_case11(<2 x half> %a) {171; NOFP16-LABEL: 'extract_case11'172; NOFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x half> %a, i32 0173; NOFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x half> %a, i32 1174; NOFP16-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %res = fmul half %0, %1175; NOFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret half %res176;177; FULLFP16-LABEL: 'extract_case11'178; FULLFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x half> %a, i32 0179; FULLFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <2 x half> %a, i32 1180; FULLFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul half %0, %1181; FULLFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret half %res182;183entry:184 %1 = extractelement <2 x half> %a, i32 0185 %2 = extractelement <2 x half> %a, i32 1186 %res = fmul half %1, %2187 ret half %res188}189 190; res = lane 0 * lane 1191define float @extract_case12(<2 x float> %a) {192; CHECK-LABEL: 'extract_case12'193; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x float> %a, i32 0194; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %1 = extractelement <2 x float> %a, i32 1195; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = fmul float %0, %1196; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %res197;198entry:199 %1 = extractelement <2 x float> %a, i32 0200 %2 = extractelement <2 x float> %a, i32 1201 %res = fmul float %1, %2202 ret float %res203}204 205; res = lane 0 + lane 1206; Use of bin-op other than fmul.207define double @extract_case13(<2 x double> %a) {208; CHECK-LABEL: 'extract_case13'209; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %0 = extractelement <2 x double> %a, i32 0210; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = extractelement <2 x double> %a, i32 1211; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %res = fadd double %0, %1212; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %res213;214entry:215 %1 = extractelement <2 x double> %a, i32 0216 %2 = extractelement <2 x double> %a, i32 1217 %res = fadd double %1, %2218 ret double %res219}220 221declare void @foo(double)222