From 637aeed70a37a1293ca102f1f684d1f98a9934fc Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 8 Oct 2016 12:15:21 +0200 Subject: [PATCH] Only allocate an output vreg if the instruction actually wants one. --- mach/proto/mcg/pass_instructionselection.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mach/proto/mcg/pass_instructionselection.c b/mach/proto/mcg/pass_instructionselection.c index 4e3edd4da..db5280280 100644 --- a/mach/proto/mcg/pass_instructionselection.c +++ b/mach/proto/mcg/pass_instructionselection.c @@ -88,6 +88,13 @@ static void constrain_input_reg(int child, int attr) static void constrain_output_reg(int attr) { + struct vreg* vreg = current_hop->output; + + if (!vreg) + current_hop->output = vreg = new_vreg(); + + array_appendu(¤t_hop->outs, vreg); + vreg->defined = current_hop; } static const struct burm_emitter_data emitter_data = @@ -161,22 +168,12 @@ static struct insn* walk_instructions(struct burm_node* node, int goal) case ir_to_esn(IR_NOP, 0): vreg = node->left->ir->result; break; - - default: - /* FIXME: some instructions don't emit anything, so - * allocating a register for them is a waste of time. */ - vreg = new_vreg(); } insn->hop = current_hop = new_hop(current_bb, insn->ir); - insn->hop->output = vreg; - if (vreg) - { - array_appendu(¤t_hop->outs, vreg); - vreg->defined = current_hop; - } - + current_hop->output = vreg; emit(insn); + hop_print('I', current_hop); array_append(¤t_bb->hops, current_hop);