X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firconsconfirm.c;h=57b8f3c5cce991f2ca0d3ab79aff275d84411c96;hb=dd4cd761ab637d4488c7e29f49843b1b02366acf;hp=c8f93461305a6de57516e238cdbd2508fc5cadcd;hpb=960d88fb7fd5805f957a66bdf7cbc034659b7a71;p=libfirm diff --git a/ir/ana/irconsconfirm.c b/ir/ana/irconsconfirm.c index c8f934613..57b8f3c5c 100644 --- a/ir/ana/irconsconfirm.c +++ b/ir/ana/irconsconfirm.c @@ -415,7 +415,31 @@ static void insert_Confirm_in_block(ir_node *block, void *env) { } /* insert_Confirm_in_block */ /** - * The given will be dereferenced, add non-null confirms. + * Checks if a node is a non-null Confirm. + */ +static int is_non_null_Confirm(const ir_node *ptr) { + /* + * While a SymConst is not a Confirm, it is non-null + * anyway. This helps to reduce the number of + * constructed Confirms. + */ + if (is_SymConst_addr_ent(ptr)) + return 1; + for (;;) { + if (! is_Confirm(ptr)) + return 0; + if (get_Confirm_cmp(ptr) == pn_Cmp_Lg) { + ir_node *bound = get_Confirm_bound(ptr); + + if (is_Const(bound) && is_Const_null(bound)) + return 1; + } + ptr = get_Confirm_value(ptr); + } +} /* is_non_null_Confirm */ + +/** + * The given pointer will be dereferenced, add non-null Confirms. * * @param ptr a node representing an address * @param block the block of the dereferencing instruction @@ -431,6 +455,11 @@ static void insert_non_null(ir_node *ptr, ir_node *block, env_t *env) { ir_node *blk; + if (is_Confirm(succ)) { + /* beware of loops */ + continue; + } + if ((is_Load(succ) || is_Store(succ)) && get_nodes_block(succ) == block) { /* Ignore Loads and Store in the same block for now, @@ -443,7 +472,7 @@ static void insert_non_null(ir_node *ptr, ir_node *block, env_t *env) { pos = get_edge_src_pos(edge); blk = get_effective_use_block(succ, pos); - if (block_dominates(block, blk)) { + if (block_dominates(block, blk) && !is_non_null_Confirm(get_irn_n(succ, pos))) { /* * Ok, we found a usage of ptr in a block * dominated by the Load/Store block. @@ -465,23 +494,6 @@ static void insert_non_null(ir_node *ptr, ir_node *block, env_t *env) { } } /* insert_non_null */ -/** - * Checks if a node is a non-null Confirm. - */ -static int is_non_null_Confirm(const ir_node *ptr) { - for (;;) { - if (! is_Confirm(ptr)) - return 0; - if (get_Confirm_cmp(ptr) == pn_Cmp_Lg) { - ir_node *bound = get_Confirm_bound(ptr); - - if (is_Const(bound) && is_Const_null(bound)) - return 1; - } - ptr = get_Confirm_value(ptr); - } -} /* is_non_null_Confirm */ - /** * Pre-walker: Called for every node to insert Confirm nodes */ @@ -571,7 +583,7 @@ static void rem_Confirm(ir_node *n, void *env) { exchange(n, value); else { /* - * Strange: a Confirm is it's own bound. This can happen + * Strange: a Confirm is its own bound. This can happen * in dead blocks when Phi nodes are already removed. */ exchange(n, new_Bad());