X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbepeephole.c;h=951e24760c79c57d1cdc6833e750de058fa262a2;hb=0bddf6c31e2dc664e50eed6609ac36a1a86e1536;hp=6f971df5ddd343883290a14ab450ac302a55ed0a;hpb=6da9f4a53cecb75224fc72978a5862085c88c01d;p=libfirm diff --git a/ir/be/bepeephole.c b/ir/be/bepeephole.c index 6f971df5d..951e24760 100644 --- a/ir/be/bepeephole.c +++ b/ir/be/bepeephole.c @@ -21,7 +21,6 @@ * @file * @brief Peephole optimisation framework keeps track of which registers contain which values * @author Matthias Braun - * @version $Id$ */ #include "config.h" @@ -33,6 +32,7 @@ #include "irprintf.h" #include "ircons.h" #include "irgmod.h" +#include "heights.h" #include "error.h" #include "beirg.h" @@ -248,6 +248,52 @@ bool be_has_only_one_user(ir_node *node) return n_users == 1; } +bool be_can_move_before(ir_heights_t *heights, const ir_node *node, + const ir_node *before) +{ + int node_arity = get_irn_arity(node); + ir_node *schedpoint = sched_next(node); + + while (schedpoint != before) { + int i; + unsigned n_outs = arch_get_irn_n_outs(schedpoint); + + /* the node must not use our computed values */ + if (heights_reachable_in_block(heights, schedpoint, node)) + return false; + + /* the node must not overwrite registers of our inputs */ + for (i = 0; i < node_arity; ++i) { + ir_node *in = get_irn_n(node, i); + const arch_register_t *reg = arch_get_irn_register(in); + const arch_register_req_t *in_req + = arch_get_irn_register_req_in(node, i); + unsigned o; + if (reg == NULL) + continue; + for (o = 0; o < n_outs; ++o) { + const arch_register_t *outreg + = arch_get_irn_register_out(schedpoint, o); + const arch_register_req_t *outreq + = arch_get_irn_register_req_out(schedpoint, o); + if (outreg == NULL) + continue; + if (outreg->global_index >= reg->global_index + && outreg->global_index + < (unsigned)reg->global_index + in_req->width) + return false; + if (reg->global_index >= outreg->global_index + && reg->global_index + < (unsigned)outreg->global_index + outreq->width) + return false; + } + } + + schedpoint = sched_next(schedpoint); + } + return true; +} + /* * Tries to optimize a beIncSP node with its previous IncSP node. * Must be run from a be_peephole_opt() context. @@ -278,10 +324,12 @@ ir_node *be_peephole_IncSP_IncSP(ir_node *node) void be_peephole_opt(ir_graph *irg) { +#if 0 /* we sometimes find BadE nodes in float apps like optest_float.c or * kahansum.c for example... */ - be_liveness_invalidate(be_get_irg_liveness(irg)); - be_liveness_assure_sets(be_assure_liveness(irg)); + be_invalidate_live_sets(irg); +#endif + be_assure_live_sets(irg); arch_env = be_get_irg_arch_env(irg); lv = be_get_irg_liveness(irg);