summaryrefslogtreecommitdiffhomepage
path: root/ir/be/bepeephole.c
diff options
context:
space:
mode:
authorSebastian Buchwald <Sebastian.Buchwald@kit.edu>2013-04-04 09:30:58 +0200
committerSebastian Buchwald <Sebastian.Buchwald@kit.edu>2013-04-04 10:53:27 +0200
commit6d6ad9f304011d62fe7cab4552789c97a3dfb47a (patch)
tree398d091bcb6e3509f169b3d4215dad9a5848c09c /ir/be/bepeephole.c
parent66af020b1651c25b9098a9d59ca5e2d475fe3b99 (diff)
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.
Diffstat (limited to 'ir/be/bepeephole.c')
-rw-r--r--ir/be/bepeephole.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/ir/be/bepeephole.c b/ir/be/bepeephole.c
index 7477b90..03cf19d 100644
--- a/ir/be/bepeephole.c
+++ b/ir/be/bepeephole.c
@@ -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))
return false;
- /* node must not overwrite registers used by schedpoint */
int arity = get_irn_arity(schedpoint);
- for (int i = 0; i < arity; ++i) {
- const arch_register_t *reg
- = arch_get_irn_register_in(schedpoint, i);
- if (reg == NULL)
+ 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 *in_req
- = arch_get_irn_register_req_in(schedpoint, i);
- be_foreach_out(node, o) {
- const arch_register_t *outreg
- = arch_get_irn_register_out(node, o);
- const arch_register_req_t *outreq
- = arch_get_irn_register_req_out(node, o);
- if (overlapping_regs(outreg, outreq, reg, in_req))
+ 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) {
+ const arch_register_t *inreg = arch_get_irn_register_in(schedpoint, i);
+ if (inreg == NULL)
+ continue;
+ const arch_register_req_t *inreq = arch_get_irn_register_req_in(schedpoint, i);
+ if (overlapping_regs(node_outreg, node_outreq, inreg, inreq))
+ return false;
+ }
+
+ /* schedpoint must not overwrite registers written by node (output dependency) */
+ be_foreach_out(schedpoint, o2) {
+ 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;
}
}