X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_blocks.c;h=78ff88dabbb506bbaa02b7f053131c5e80889701;hb=4cef2a70fbdc26498af3540fb1d07d96fbd56d56;hp=7b7c4a9891c60512340b1642547f45fe86ecee89;hpb=e17ea9839630a00ea7ec1300c566b8c813dcab5f;p=libfirm diff --git a/ir/opt/opt_blocks.c b/ir/opt/opt_blocks.c index 7b7c4a989..78ff88dab 100644 --- a/ir/opt/opt_blocks.c +++ b/ir/opt/opt_blocks.c @@ -23,8 +23,7 @@ * @author Michael Beck * @version $Id$ * - * This phase find congruent blocks. Works currently for - * predecessors of the end block only. + * This phase find congruent blocks. * Two block are congruent, if they contains only equal calculations. */ #include "config.h" @@ -40,7 +39,8 @@ #include "set.h" #include "debug.h" -/* define this for gneral block shaping */ +/* define this for general block shaping: congruent blocks + are found not only before the end block but anywhere in the graph */ #define GENERAL_SHAPE typedef struct partition_t partition_t; @@ -64,6 +64,7 @@ struct opcode_key_t { tarval *tv; /**< For Const nodes, its tarval */ symconst_symbol sym; /**< For SymConst nodes, its symbol .*/ void *addr; /**< Alias all addresses. */ + int intVal; /**< For Conv/Div nodes: strict/remainderless. */ } u; }; @@ -250,6 +251,7 @@ static listmap_entry_t *listmap_find(listmap_t *map, void *id) { * @return a hash value for the given opcode map entry */ static unsigned opcode_hash(const opcode_key_t *entry) { + /* assume long >= int */ return (entry->mode - (ir_mode *)0) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.addr) + entry->arity; } /* opcode_hash */ @@ -404,6 +406,18 @@ static opcode_key_t *opcode(const node_t *node, environment_t *env) { case iro_Const: key.u.tv = get_Const_tarval(irn); break; + case iro_Conv: + key.u.intVal = get_Conv_strict(irn); + break; + case iro_Load: + key.mode = get_Load_mode(irn); + break; + case iro_Div: + key.u.intVal = get_Div_no_remainder(irn); + break; + case iro_Builtin: + key.u.intVal = get_Builtin_kind(irn); + break; default: break; } @@ -452,7 +466,7 @@ static partition_t *split(partition_t *Z, block_t *g, environment_t *env) { } /* split */ /** - * Rteurn non-zero if pred should be tread as a input node. + * Return non-zero if pred should be tread as a input node. */ static int is_input_node(ir_node *pred, ir_node *irn, int index) { /* for now, do NOT turn direct calls into indirect one */ @@ -536,7 +550,7 @@ void propagate_blocks(partition_t *part, environment_t *env) { DB((dbg, LEVEL_3, " propagate Input %+F\n", node->node)); } - /* Add bl to map[opcode(bl)]. */ + /* Add bl to map[opcode(n)]. */ id = opcode(node, env); entry = listmap_find(&map, id); bl->next = entry->list; @@ -1126,7 +1140,7 @@ static void add_roots(ir_graph *irg, environment_t *env) { } /* * Now sort the roots to normalize them as good as possible. - * Else, we will split identical blocks if we start which different roots + * Else, we will split identical blocks if we start which different roots. */ for (bl = env->all_blocks; bl != NULL; bl = bl->all_next) { int i, n = ARR_LEN(bl->roots);