From e13ff5be315820ac593656788f6b1060ba1032fc Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 4 Oct 2016 21:29:03 +0200 Subject: [PATCH] Don't allocate new vregs for REG and NOP --- a bit hacky, but suppresses stray movs very effectively. --- mach/proto/mcg/pass_instructionselection.c | 18 +++++++++++++++++- mach/proto/mcg/table | 2 -- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mach/proto/mcg/pass_instructionselection.c b/mach/proto/mcg/pass_instructionselection.c index 20a93c697..48ede30df 100644 --- a/mach/proto/mcg/pass_instructionselection.c +++ b/mach/proto/mcg/pass_instructionselection.c @@ -129,8 +129,24 @@ static struct insn* walk_instructions(struct burm_node* node, int goal) if (!insn->insndata->is_fragment) { + struct vreg* vreg = NULL; + + switch (node->label) + { + case ir_to_esn(IR_REG, 0): + vreg = node->ir->result; + break; + + case ir_to_esn(IR_NOP, 0): + vreg = node->left->ir->result; + break; + + default: + vreg = new_vreg(); + } + insn->hop = current_hop = new_hop(0, insn->ir); - insn->hop->output = new_vreg(); + insn->hop->output = vreg; emit(insn); hop_print('I', current_hop); diff --git a/mach/proto/mcg/table b/mach/proto/mcg/table index 0fa07b6bc..4d892c069 100644 --- a/mach/proto/mcg/table +++ b/mach/proto/mcg/table @@ -69,11 +69,9 @@ PATTERNS cost 4; reg = in:REG - emit "mov %reg, %in" cost 1; reg = NOP(in:reg) - emit "mov %reg, %in" cost 1; -- 2.34.1