From 3e58f554ed44a636f08eabfb1cd6b270f74c4d71 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 10 Aug 2023 13:29:32 -0400 Subject: [PATCH] [mono][llvm] Use the OP_MEMMOVE opcode instead of calling the managed memcpy method when compiling with LLVM. (#90097) LLVM can emit optimized code when the length ends up being a constant. --- src/mono/mono/mini/memory-access.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/memory-access.c b/src/mono/mono/mini/memory-access.c index 58d9c54..ceae7a3 100644 --- a/src/mono/mono/mini/memory-access.c +++ b/src/mono/mono/mini/memory-access.c @@ -210,7 +210,16 @@ mini_emit_memcpy_internal (MonoCompile *cfg, MonoInst *dest, MonoInst *src, Mono if (!size_ins) EMIT_NEW_ICONST (cfg, size_ins, size); iargs [2] = size_ins; - mono_emit_method_call (cfg, mini_get_memcpy_method (), iargs, NULL); + if (COMPILE_LLVM (cfg)) { + MonoInst *ins; + MONO_INST_NEW (cfg, ins, OP_MEMMOVE); + ins->sreg1 = iargs [0]->dreg; + ins->sreg2 = iargs [1]->dreg; + ins->sreg3 = iargs [2]->dreg; + MONO_ADD_INS (cfg->cbb, ins); + } else { + mono_emit_method_call (cfg, mini_get_memcpy_method (), iargs, NULL); + } } else { mini_emit_memcpy (cfg, dest->dreg, 0, src->dreg, 0, size, align); } -- 2.7.4