From: Matthias Braun Date: Mon, 30 May 2011 14:21:52 +0000 (+0200) Subject: improve our 'don't use AM' heuristic: immediates do not increase register pressure X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=26d5b80559148908df24bb9c265d83207a62f044;p=libfirm improve our 'don't use AM' heuristic: immediates do not increase register pressure --- diff --git a/ir/be/ia32/ia32_address_mode.c b/ir/be/ia32/ia32_address_mode.c index 5e2aea2af..2b4ff29b4 100644 --- a/ir/be/ia32/ia32_address_mode.c +++ b/ir/be/ia32/ia32_address_mode.c @@ -418,7 +418,8 @@ int ia32_is_non_address_mode_node(ir_node const *node) } /** - * Check if a given value is last used (i.e. die after) the block of some other node. + * Check if a given value is last used (i.e. die after) the block of some + * other node. */ static int value_last_used_here(be_lv_t *lv, ir_node *here, ir_node *value) { @@ -441,6 +442,12 @@ static int value_last_used_here(be_lv_t *lv, ir_node *here, ir_node *value) return 1; } +static bool simple_is_immediate(const ir_node *node) +{ + int symconsts = 0; + return do_is_immediate(node, &symconsts, false); +} + /** * Walker: mark those nodes that cannot be part of an address mode because * their value must be accessed through a register @@ -486,12 +493,17 @@ static void mark_non_address_nodes(ir_node *node, void *env) left = get_binop_left(node); right = get_binop_right(node); - /* Fold AM if any of the two operands does not die here. This duplicates + /* if any of the operands is an immediate then this will not + * increase register pressure */ + if (simple_is_immediate(left) || simple_is_immediate(right)) + return; + + /* 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(lv, node, left) || - !value_last_used_here(lv, node, right)) { + !value_last_used_here(lv, node, right)) { return; }