From: David Given Date: Tue, 31 Jan 2017 21:58:47 +0000 (+0100) Subject: Fix bug in the copy-to-move code where some copies where being erroneously X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e9cd951a172a2544f8acd385f46f7d2413219c72;p=ack.git Fix bug in the copy-to-move code where some copies where being erroneously ignored. --- diff --git a/mach/proto/mcg/pass_copiestomoves.c b/mach/proto/mcg/pass_copiestomoves.c index 4a0150eb5..de2cf20d3 100644 --- a/mach/proto/mcg/pass_copiestomoves.c +++ b/mach/proto/mcg/pass_copiestomoves.c @@ -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); - } } } } diff --git a/mach/proto/mcg/procedure.c b/mach/proto/mcg/procedure.c index 32bf39306..129df5388 100644 --- a/mach/proto/mcg/procedure.c +++ b/mach/proto/mcg/procedure.c @@ -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');