X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ffp-vrp.c;h=1ecafd1f361f32ecc0412d478e76abaeae25adc3;hb=762b472fc81c73cf7a1b0041b8cd286b7206d79d;hp=90562918c5d04c3d9427673a039056bf2f96270c;hpb=d5358b95c8dcf2c101181e9cd293953960e8c58d;p=libfirm diff --git a/ir/opt/fp-vrp.c b/ir/opt/fp-vrp.c index 90562918c..1ecafd1f3 100644 --- a/ir/opt/fp-vrp.c +++ b/ir/opt/fp-vrp.c @@ -25,6 +25,7 @@ */ #include "config.h" +#include #include #include "adt/pdeq.h" @@ -35,9 +36,9 @@ #include "irdom.h" #include "iredges.h" #include "irgmod.h" -#include "irgraph.h" +#include "irgraph_t.h" #include "irgwalk.h" -#include "irnode.h" +#include "irnode_t.h" #include "iroptimize.h" #include "irtools.h" #include "tv.h" @@ -151,6 +152,10 @@ static int set_bitinfo(ir_node* const irn, ir_tarval* const z, ir_tarval* const set_irn_link(irn, b); } else if (z == b->z && o == b->o) { return 0; + } else { + /* Assert monotonicity. */ + assert(tarval_is_null(tarval_andnot(b->z, z))); + assert(tarval_is_null(tarval_andnot(o, b->o))); } b->z = z; b->o = o; @@ -171,6 +176,8 @@ static int transfer(ir_node* const irn) ir_tarval* z; ir_tarval* o; + if (is_Bad(irn)) return 0; + if (m == mode_X) { bitinfo* const b = get_bitinfo(get_nodes_block(irn)); @@ -270,7 +277,7 @@ result_unknown_X: DB((dbg, LEVEL_3, "transfer %+F\n", irn)); - if (b->z == f) { + if (b == NULL || b->z == f) { undefined: z = get_tarval_null(m); o = get_tarval_all_one(m); @@ -316,6 +323,11 @@ undefined: /* TODO Use bound and relation. */ z = b->z; o = b->o; + if ((get_Confirm_relation(irn) & ~ir_relation_unordered) == ir_relation_equal) { + bitinfo* const bound_b = get_bitinfo(get_Confirm_bound(irn)); + z = tarval_and(z, bound_b->z); + o = tarval_or( o, bound_b->o); + } break; } @@ -627,6 +639,18 @@ static void first_round(ir_node* const irn, void* const env) } } +static ir_node *make_bad_block(ir_graph *irg) +{ + ir_node *bad = new_r_Bad(irg, mode_BB); + bitinfo *bb = get_bitinfo(bad); + if (bb == NULL) { + ir_tarval* const f = get_tarval_b_false(); + ir_tarval* const t = get_tarval_b_true(); + set_bitinfo(bad, f, t); /* Undefined. */ + } + return bad; +} + static void apply_result(ir_node* const irn, void* ctx) { environment_t* env = (environment_t*)ctx; @@ -640,7 +664,8 @@ static void apply_result(ir_node* const irn, void* ctx) block_b = get_bitinfo(irn); /* Trivially unreachable blocks have no info. */ if (block_b == NULL || block_b->z == get_tarval_b_false()) { - exchange(irn, get_irg_bad(get_Block_irg(irn))); + ir_node *bad = make_bad_block(get_irn_irg(irn)); + exchange(irn, bad); env->modified = 1; } return; @@ -651,7 +676,10 @@ static void apply_result(ir_node* const irn, void* ctx) /* Trivially unreachable blocks have no info. */ if (block_b == NULL || block_b->z == get_tarval_b_false()) { /* Unreachable blocks might be replaced before the nodes in them. */ - exchange(irn, is_Bad(block) ? block : get_irg_bad(get_Block_irg(block))); + ir_mode *mode = get_irn_mode(irn); + ir_graph *irg = get_irn_irg(irn); + ir_node *bad = new_r_Bad(irg, mode); + exchange(irn, bad); env->modified = 1; return; } @@ -680,7 +708,7 @@ static void apply_result(ir_node* const irn, void* ctx) add_End_keepalive(get_irg_end(irg), block); n = new_r_Jmp(block); } else { - n = new_r_Bad(irg); + n = new_r_Bad(irg, mode_X); /* Transferring analysis information to the bad node makes it a * candidate for replacement. */ goto exchange_only; @@ -805,13 +833,13 @@ void fixpoint_vrp(ir_graph* const irg) { pdeq* const q = new_pdeq(); - /* We need this extra step because the dom tree does not contain unreachable - blocks in Firm. Moreover build phi list. */ + /* We need this extra step because the dom tree does not contain + * unreachable blocks in Firm. Moreover build phi list. */ irg_walk_anchors(irg, clear_links, build_phi_lists, NULL); - { ir_tarval* const f = get_tarval_b_false(); + { + ir_tarval* const f = get_tarval_b_false(); ir_tarval* const t = get_tarval_b_true(); - set_bitinfo(get_irg_bad(irg), f, t); /* Undefined. */ set_bitinfo(get_irg_end_block(irg), t, f); /* Reachable. */ } @@ -834,10 +862,8 @@ void fixpoint_vrp(ir_graph* const irg) if (env.modified) { /* control flow might changed */ - set_irg_outs_inconsistent(irg); set_irg_extblk_inconsistent(irg); set_irg_doms_inconsistent(irg); - set_irg_loopinfo_inconsistent(irg); set_irg_entity_usage_state(irg, ir_entity_usage_not_computed); }