From d62c701a43b255195b1d0dc2f7d80afa40d2b5fe Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 25 Oct 2021 01:03:16 +0100 Subject: Improve matrix code generation for all supported platforms Through assembly optimization --- src/llvm_backend_utility.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/llvm_backend_utility.cpp') diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index e458c0692..af773d467 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -1492,7 +1492,26 @@ lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t b = lb_emit_conv(p, b, t); c = lb_emit_conv(p, c, t); - if (!is_type_different_to_arch_endianness(t) && is_type_float(t)) { + bool is_possible = !is_type_different_to_arch_endianness(t) && is_type_float(t); + + if (is_possible) { + switch (build_context.metrics.arch) { + case TargetArch_amd64: + if (type_size_of(t) == 2) { + is_possible = false; + } + break; + case TargetArch_arm64: + // possible + break; + case TargetArch_386: + case TargetArch_wasm32: + is_possible = false; + break; + } + } + + if (is_possible) { char const *name = "llvm.fma"; unsigned id = LLVMLookupIntrinsicID(name, gb_strlen(name)); GB_ASSERT_MSG(id != 0, "Unable to find %s", name); -- cgit v1.2.3