X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fia32%2Fia32_address_mode.c;h=1a7a693543c424e3b3b7c4623f6a65d1a29bd769;hb=4b345ae315bf1c47a0a98a4bcc60d4ec28086236;hp=ac876fcdd0e37154d692199fdc11c902b95e1440;hpb=d1fb00e4e6be827d758a141ef4c55472f518e854;p=libfirm diff --git a/ir/be/ia32/ia32_address_mode.c b/ir/be/ia32/ia32_address_mode.c index ac876fcdd..1a7a69354 100644 --- a/ir/be/ia32/ia32_address_mode.c +++ b/ir/be/ia32/ia32_address_mode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -418,6 +418,27 @@ void ia32_mark_non_am(ir_node *node) bitset_set(non_address_mode_nodes, get_irn_idx(node)); } +static int value_last_used_here(ir_node *here, ir_node *value) +{ + ir_node *block = get_nodes_block(here); + const ir_edge_t *edge; + + /* If the value is live end it is for sure it does not die here */ + if (be_is_live_end(lv, block, value)) return 0; + + /* if multiple nodes in this block use the value, then we cannot decide + * whether the value will die here (because there is no schedule yet). + * Assume it does not die in this case. */ + foreach_out_edge(value, edge) { + ir_node *user = get_edge_src_irn(edge); + if (user != here && get_nodes_block(user) == block) { + return 0; + } + } + + return 1; +} + /** * Walker: mark those nodes that cannot be part of an address mode because * there value must be access through an register @@ -426,11 +447,9 @@ static void mark_non_address_nodes(ir_node *node, void *env) { int i, arity; ir_node *val; - ir_node *block; ir_node *left; ir_node *right; ir_mode *mode; - const ir_edge_t *edge; (void) env; mode = get_irn_mode(node); @@ -461,28 +480,16 @@ static void mark_non_address_nodes(ir_node *node, void *env) * pressure. Otherwise we fold them in aggressively in the hope, that * the node itself doesn't exist anymore and we were able to save the * register for the result */ - block = get_nodes_block(node); left = get_binop_left(node); right = get_binop_right(node); - /* If both are live end not folding AM costs a register */ - if(be_is_live_end(lv, block, left) && be_is_live_end(lv, block, right)) + /* Fold AM if any of the two operands does not die here. This duplicates + * an addition and has the same register pressure for the case that only + * one operand dies, but is faster (on Pentium 4). + * && instead of || only folds AM if both operands do not die here */ + if (!value_last_used_here(node, left) || + !value_last_used_here(node, right)) { return; - - /* if multiple nodes in this block use left/right values, then we - * can't really decide wether the values will die after node. - * We use aggressive mode then, since it's usually just multiple address - * calculations. */ - foreach_out_edge(left, edge) { - ir_node *user = get_edge_src_irn(edge); - if(user != node && get_nodes_block(user) == block) { - foreach_out_edge(right, edge) { - ir_node *user = get_edge_src_irn(edge); - if(user != node && get_nodes_block(user) == block) - return; - } - break; - } } /* At least one of left and right are not used by anyone else, so it is