From f6697e30681f46f6f3f632ddbbcab98107eec7e0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 18 Sep 2014 12:27:01 +0200 Subject: compiler: generate only 1 temp for constants Generate only 1 temp variable for constants. We do this by keeping track of what variable we used to replace the constant. Previously, orc would allocate a new temp variable every time a constant was used, this wastes registers and is not needed. --- orc/orccompiler.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/orc/orccompiler.c b/orc/orccompiler.c index 1b403f5..575775b 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -582,6 +582,13 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) OrcInstruction *cinsn; int multiplier; + if (var->vartype == ORC_VAR_TYPE_CONST) { + if (var->replaced) { + insn.src_args[i] = var->replacement; + continue; + } + } + cinsn = compiler->insns + compiler->n_insns; compiler->n_insns++; @@ -598,13 +605,16 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) cinsn->opcode = get_loadp_opcode_for_size (opcode->src_size[i]); cinsn->dest_args[0] = orc_compiler_new_temporary (compiler, opcode->src_size[i] * multiplier); + if (var->vartype == ORC_VAR_TYPE_CONST) { + var->replaced = TRUE; + var->replacement = cinsn->dest_args[0]; + compiler->vars[cinsn->dest_args[0]].flags |= ORC_VAR_FLAG_VOLATILE_WORKAROUND; } cinsn->src_args[0] = insn.src_args[i]; insn.src_args[i] = cinsn->dest_args[0]; - } } } -- cgit v1.2.3