Fix bug in the copy-to-move code where some copies where being erroneously
authorDavid Given <dg@cowlark.com>
Tue, 31 Jan 2017 21:58:47 +0000 (22:58 +0100)
committerDavid Given <dg@cowlark.com>
Tue, 31 Jan 2017 21:58:47 +0000 (22:58 +0100)
ignored.

mach/proto/mcg/pass_copiestomoves.c
mach/proto/mcg/procedure.c

index 4a0150e..de2cf20 100644 (file)
@@ -19,13 +19,16 @@ void pass_convert_copies_to_moves(void)
                 {
                     struct vreg* in = hop->vregusage.item[k].left;
                     struct vreg* out = hop->vregusage.item[k].right;
+                    static struct valueusage dummyusage = {};
+                    struct valueusage* inusage = in ? hop_get_value_usage(hop, in->value) : &dummyusage;
+                    struct valueusage* outusage = out ? hop_get_value_usage(hop, out->value) : &dummyusage;
 
-                    if (in && !out)
+                    if (inusage->input && !inusage->output)
                     {
                         assert(!invreg);
                         invreg = in;
                     }
-                    if (!in && out)
+                    if (!inusage->input && outusage->output)
                     {
                         assert(!outvreg);
                         outvreg = out;
@@ -33,12 +36,7 @@ void pass_convert_copies_to_moves(void)
                 }
 
                 if (invreg && outvreg)
-                {
-                    struct valueusage* usage = hop_get_value_usage(hop, outvreg->value);
-                    assert(!usage->input);
-                    usage->input = true;
                     hop_add_through_vreg(hop, invreg, outvreg);
-                }
             }
         }
     }
index 32bf393..129df53 100644 (file)
@@ -226,6 +226,7 @@ void procedure_compile(struct procedure* proc)
     pass_convert_copies_to_moves();
     print_hops('9');
     pass_register_allocator();
+    print_hops('a');
 #if 0
     pass_add_prologue_epilogue();
     print_hops('9');