Commit 6d6ad9f3 authored by yb9976's avatar yb9976
Browse files

Do not move instructions upwards if there is an output dependency.

The code requires assigned registers but no kept Proj.

This fixes backend/udiv.c on SPARC.
parent 66af020b
...@@ -338,21 +338,30 @@ bool be_can_move_up(ir_heights_t *heights, const ir_node *node, ...@@ -338,21 +338,30 @@ bool be_can_move_up(ir_heights_t *heights, const ir_node *node,
if (heights_reachable_in_block(heights, node, schedpoint)) if (heights_reachable_in_block(heights, node, schedpoint))
return false; return false;
/* node must not overwrite registers used by schedpoint */
int arity = get_irn_arity(schedpoint); int arity = get_irn_arity(schedpoint);
be_foreach_out(node, o) {
const arch_register_t *node_outreg = arch_get_irn_register_out(node, o);
if (node_outreg == NULL)
continue;
const arch_register_req_t *node_outreq = arch_get_irn_register_req_out(node, o);
/* node must not overwrite registers used by schedpoint (anti dependency) */
for (int i = 0; i < arity; ++i) { for (int i = 0; i < arity; ++i) {
const arch_register_t *reg const arch_register_t *inreg = arch_get_irn_register_in(schedpoint, i);
= arch_get_irn_register_in(schedpoint, i); if (inreg == NULL)
if (reg == NULL)
continue; continue;
const arch_register_req_t *in_req const arch_register_req_t *inreq = arch_get_irn_register_req_in(schedpoint, i);
= arch_get_irn_register_req_in(schedpoint, i); if (overlapping_regs(node_outreg, node_outreq, inreg, inreq))
be_foreach_out(node, o) { return false;
const arch_register_t *outreg }
= arch_get_irn_register_out(node, o);
const arch_register_req_t *outreq /* schedpoint must not overwrite registers written by node (output dependency) */
= arch_get_irn_register_req_out(node, o); be_foreach_out(schedpoint, o2) {
if (overlapping_regs(outreg, outreq, reg, in_req)) const arch_register_t *outreg = arch_get_irn_register_out(schedpoint, o2);
if (outreg == NULL)
continue;
const arch_register_req_t *outreq = arch_get_irn_register_req_out(schedpoint, o2);
if (overlapping_regs(node_outreg, node_outreq, outreg, outreq))
return false; return false;
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment