Don't allocate new vregs for REG and NOP --- a bit hacky, but suppresses stray
authorDavid Given <dg@cowlark.com>
Tue, 4 Oct 2016 19:29:03 +0000 (21:29 +0200)
committerDavid Given <dg@cowlark.com>
Tue, 4 Oct 2016 19:29:03 +0000 (21:29 +0200)
movs very effectively.

mach/proto/mcg/pass_instructionselection.c
mach/proto/mcg/table

index 20a93c6..48ede30 100644 (file)
@@ -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);
 
index 0fa07b6..4d892c0 100644 (file)
@@ -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;