X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firscc.c;h=d0b684b3172e98d716b60a970c455ec0644616f0;hb=b2e280bcb4dcde092a0971ea045ee1269b114c4f;hp=bccdd5c424fd7c4957cb57731741fba3903d248b;hpb=1ba00901371680626dc22ab9658bc7339d2dd9ab;p=libfirm diff --git a/ir/ana/irscc.c b/ir/ana/irscc.c index bccdd5c42..d0b684b31 100644 --- a/ir/ana/irscc.c +++ b/ir/ana/irscc.c @@ -1,18 +1,32 @@ /* - * Project: libFIRM - * File name: ir/ana/irscc.c - * Purpose: Compute the strongly connected regions and build + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/** + * @file + * @brief Compute the strongly connected regions and build * backedge/loop datastructures. * A variation on the Tarjan algorithm. See also [Trapp:99], * Chapter 5.2.1.2. - * Author: Goetz Lindenmaier - * Modified by: - * Created: 7.2002 - * CVS-ID: $Id$ - * Copyright: (c) 2002-2003 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * @author Goetz Lindenmaier + * @date 7.2002 + * @version $Id$ */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -64,9 +78,9 @@ ir_node *get_projx_link(ir_node *cb_projx); /**********************************************************************/ typedef struct scc_info { - bool in_stack; /* Marks whether node is on the stack. */ - int dfn; /* Depth first search number. */ - int uplink; /* dfn number of ancestor. */ + int in_stack; /**< Marks whether node is on the stack. */ + int dfn; /**< Depth first search number. */ + int uplink; /**< dfn number of ancestor. */ /* ir_loop *loop; *//* Refers to the containing loop. */ /* struct section *section; @@ -85,17 +99,17 @@ static INLINE void mark_irn_in_stack (ir_node *n) { scc_info *scc = get_irn_link(n); assert(scc); - scc->in_stack = true; + scc->in_stack = 1; } static INLINE void mark_irn_not_in_stack (ir_node *n) { scc_info *scc = get_irn_link(n); assert(scc); - scc->in_stack = false; + scc->in_stack = 0; } -static INLINE bool +static INLINE int irn_is_in_stack (ir_node *n) { scc_info *scc = get_irn_link(n); assert(scc); @@ -137,9 +151,8 @@ set_irn_loop (ir_node *n, ir_loop *loop) { } /* Uses temporary information to get the loop */ -ir_loop * -get_irn_loop (ir_node *n) { - return n->loop; +ir_loop *(get_irn_loop)(const ir_node *n) { + return _get_irn_loop(n); } @@ -206,8 +219,6 @@ static INLINE void free_stack(void) { static INLINE void push (ir_node *n) { - /*DDMN(n);*/ - if (tos == ARR_LEN (stack)) { int nlen = ARR_LEN (stack) * 2; ARR_RESIZE (ir_node *, stack, nlen); @@ -242,8 +253,6 @@ pop_scc_to_loop (ir_node *n) do { m = pop(); - //printf(" dfn: %d, upl %d upl-new %d ", get_irn_dfn(m), get_irn_uplink(m), loop_node_cnt+1); DDMN(m); - loop_node_cnt++; set_irn_dfn(m, loop_node_cnt); add_loop_node(current_loop, m); @@ -351,21 +360,18 @@ static void mature_loop (ir_loop *loop) { #endif /* Returns outer loop, itself if outermost. */ -ir_loop *get_loop_outer_loop (ir_loop *loop) { - assert(loop && loop->kind == k_ir_loop); - return loop->outer_loop; +ir_loop *(get_loop_outer_loop)(const ir_loop *loop) { + return _get_loop_outer_loop(loop); } /* Returns nesting depth of this loop */ -int get_loop_depth (ir_loop *loop) { - assert(loop); assert(loop->kind == k_ir_loop); - return loop->depth; +int (get_loop_depth)(const ir_loop *loop) { + return _get_loop_depth(loop); } /* Returns the number of inner loops */ -int get_loop_n_sons (ir_loop *loop) { - assert(loop && loop->kind == k_ir_loop); - return(loop -> n_sons); +int (get_loop_n_sons)(const ir_loop *loop) { + return _get_loop_n_sons(loop); } /* Returns the pos`th loop_node-child * @@ -421,8 +427,7 @@ ir_node *get_loop_node (ir_loop *loop, int pos) { if(node_nr == pos) return(loop -> children[child_nr].node); } - DDML(loop); - printf("pos: %d\n", pos); + assert(0 && "no child at pos found"); return NULL; } @@ -440,8 +445,8 @@ add_loop_node(ir_loop *loop, ir_node *n) { loop->n_nodes++; } -/** Returns the number of elements contained in loop. */ -int get_loop_n_elements (ir_loop *loop) { +/* Returns the number of elements contained in loop. */ +int get_loop_n_elements (const ir_loop *loop) { assert(loop && loop->kind == k_ir_loop); return(ARR_LEN(loop->children)); } @@ -453,22 +458,22 @@ int get_loop_n_elements (ir_loop *loop) { and then select the appropriate "loop_element.node" or "loop_element.son". */ -loop_element get_loop_element (ir_loop *loop, int pos) { +loop_element get_loop_element(const ir_loop *loop, int pos) { assert(loop && loop->kind == k_ir_loop && pos < ARR_LEN(loop->children)); - return(loop -> children[pos]); } -int get_loop_element_pos(ir_loop *loop, void *le) { - int i; +int get_loop_element_pos(const ir_loop *loop, void *le) { + int i, n; assert(loop && loop->kind == k_ir_loop); - for (i = 0; i < get_loop_n_elements(loop); i++) + n = get_loop_n_elements(loop); + for (i = 0; i < n; i++) if (get_loop_element(loop, i).node == le) return i; return -1; } -int get_loop_loop_nr(ir_loop *loop) { +int get_loop_loop_nr(const ir_loop *loop) { assert(loop && loop->kind == k_ir_loop); #ifdef DEBUG_libfirm return loop->loop_nr; @@ -482,17 +487,11 @@ int get_loop_loop_nr(ir_loop *loop) { if libfirm_debug is set. */ void set_loop_link (ir_loop *loop, void *link) { assert(loop && loop->kind == k_ir_loop); -#ifdef DEBUG_libfirm loop->link = link; -#endif } void *get_loop_link (const ir_loop *loop) { assert(loop && loop->kind == k_ir_loop); -#ifdef DEBUG_libfirm return loop->link; -#else - return NULL; -#endif } int (is_ir_loop)(const void *thing) { @@ -518,6 +517,7 @@ ir_loop *(get_irg_loop)(ir_graph *irg) { static INLINE void init_node (ir_node *n, void *env) { + (void) env; set_irn_link (n, new_scc_info()); clear_backedges(n); } @@ -538,6 +538,7 @@ init_scc (ir_graph *irg) { */ } +#ifdef INTERPROCEDURAL_VIEW static INLINE void init_ip_scc (void) { init_scc_common(); @@ -547,16 +548,17 @@ init_ip_scc (void) { cg_walk (link_to_reg_end, NULL, NULL); #endif } +#endif /* Condition for breaking the recursion. */ -static bool is_outermost_Start(ir_node *n) { +static int is_outermost_Start(ir_node *n) { /* Test whether this is the outermost Start node. If so recursion must end. */ if ((get_irn_op(n) == op_Block) && (get_Block_n_cfgpreds(n) == 1) && (get_irn_op(skip_Proj(get_Block_cfgpred(n, 0))) == op_Start) && (get_nodes_block(skip_Proj(get_Block_cfgpred(n, 0))) == n)) { - return true; + return 1; } #if 0 /* @@@ Bad condition: @@ -567,10 +569,10 @@ static bool is_outermost_Start(ir_node *n) { (n == get_irg_start_block(current_ir_graph))) { if ((!get_interprocedural_view()) || (current_ir_graph == outermost_ir_graph)) - return true; + return 1; } #endif - return false; + return 0; } /* When to walk from nodes to blocks. Only for Control flow operations? */ @@ -611,39 +613,19 @@ get_start_index(ir_node *n) { #endif } - -#if 0 -static void test(ir_node *pred, ir_node *root, ir_node *this) { - int i; - if (get_irn_uplink(pred) >= get_irn_uplink(root)) return; - - printf("this: %d ", get_irn_uplink(this)); DDMN(this); - printf("pred: %d ", get_irn_uplink(pred)); DDMN(pred); - printf("root: %d ", get_irn_uplink(root)); DDMN(root); - - printf("tos: %d\n", tos); - - for (i = tos; i >= 0; i--) { - ir_node *n = stack[i]; - if (!n) continue; - printf(" uplink: %d, pos: %d ", get_irn_uplink(n), i); DDMN(n); - } -} -#endif - /* Test for legal loop header: Block, Phi, ... */ -static INLINE bool is_possible_loop_head(ir_node *n) { +static INLINE int is_possible_loop_head(ir_node *n) { ir_op *op = get_irn_op(n); return ((op == op_Block) || - (op == op_Phi) || - ((op == op_Filter) && get_interprocedural_view())); + (op == op_Phi) || + ((op == op_Filter) && get_interprocedural_view())); } -/* Returns true if n is a loop header, i.e., it is a Block, Phi +/* Returns non-zero if n is a loop header, i.e., it is a Block, Phi or Filter node and has predecessors within the loop and out of the loop. @arg root: only needed for assertion. */ -static bool +static int is_head (ir_node *n, ir_node *root) { int i, arity; @@ -651,7 +633,7 @@ is_head (ir_node *n, ir_node *root) /* Test for legal loop header: Block, Phi, ... */ if (!is_possible_loop_head(n)) - return false; + return 0; if (!is_outermost_Start(n)) { arity = get_irn_arity(n); @@ -660,24 +642,25 @@ is_head (ir_node *n, ir_node *root) assert(pred); if (is_backedge(n, i)) continue; if (!irn_is_in_stack(pred)) { - some_outof_loop = 1; + some_outof_loop = 1; } else { - if(get_irn_uplink(pred) < get_irn_uplink(root)) { - DDMN(n); DDMN(pred); DDMN(root); - assert(get_irn_uplink(pred) >= get_irn_uplink(root)); - } - some_in_loop = 1; + if(get_irn_uplink(pred) < get_irn_uplink(root)) { + assert(get_irn_uplink(pred) >= get_irn_uplink(root)); + } + some_in_loop = 1; } } } return some_outof_loop && some_in_loop; } -/* Returns true if n is possible loop head of an endless loop. - I.e., it is a Block, Phi or Filter node and has only predecessors - within the loop. - @arg root: only needed for assertion. */ -static bool +/** + * Returns non-zero if n is possible loop head of an endless loop. + * I.e., it is a Block, Phi or Filter node and has only predecessors + * within the loop. + * @param root: only needed for assertion. + */ +static int is_endless_head (ir_node *n, ir_node *root) { int i, arity; @@ -685,7 +668,7 @@ is_endless_head (ir_node *n, ir_node *root) /* Test for legal loop header: Block, Phi, ... */ if (!is_possible_loop_head(n)) - return false; + return 0; if (!is_outermost_Start(n)) { arity = get_irn_arity(n); @@ -694,13 +677,12 @@ is_endless_head (ir_node *n, ir_node *root) assert(pred); if (is_backedge(n, i)) { continue; } if (!irn_is_in_stack(pred)) { - some_outof_loop = 1; //printf(" some out of loop "); + some_outof_loop = 1; //printf(" some out of loop "); } else { - if(get_irn_uplink(pred) < get_irn_uplink(root)) { - DDMN(pred); DDMN(root); - assert(get_irn_uplink(pred) >= get_irn_uplink(root)); - } - some_in_loop = 1; + if(get_irn_uplink(pred) < get_irn_uplink(root)) { + assert(get_irn_uplink(pred) >= get_irn_uplink(root)); + } + some_in_loop = 1; } } } @@ -721,8 +703,8 @@ smallest_dfn_pred (ir_node *n, int limit) assert(pred); if (is_backedge(n, i) || !irn_is_in_stack(pred)) continue; if (get_irn_dfn(pred) >= limit && (min == -1 || get_irn_dfn(pred) < min)) { - index = i; - min = get_irn_dfn(pred); + index = i; + min = get_irn_dfn(pred); } } } @@ -741,8 +723,8 @@ largest_dfn_pred (ir_node *n) ir_node *pred = get_irn_n(n, i); if (is_backedge (n, i) || !irn_is_in_stack(pred)) continue; if (get_irn_dfn(pred) > max) { - index = i; - max = get_irn_dfn(pred); + index = i; + max = get_irn_dfn(pred); } } } @@ -778,21 +760,21 @@ find_tail (ir_node *n) { m = stack[i]; if (is_head (m, n)) { - res_index = smallest_dfn_pred (m, get_irn_dfn(m) + 1); - if (res_index == -2) /* no smallest dfn pred found. */ - res_index = largest_dfn_pred (m); - - if ((m == n) && (res_index == -2)) { /* dont walk past loop head. */ - i = -1; - } - break; + res_index = smallest_dfn_pred (m, get_irn_dfn(m) + 1); + if (res_index == -2) /* no smallest dfn pred found. */ + res_index = largest_dfn_pred (m); + + if ((m == n) && (res_index == -2)) { /* dont walk past loop head. */ + i = -1; + } + break; } /* We should not walk past our selves on the stack: The upcoming nodes - are not in this loop. We assume a loop not reachable from Start. */ - if (m == n) { - i = -1; - break; + are not in this loop. We assume a loop not reachable from Start. */ + if (m == n) { + i = -1; + break; } } @@ -800,14 +782,14 @@ find_tail (ir_node *n) { if (i < 0) { /* A dead loop not reachable from Start. */ for (i = tos-2; i >= 0; --i) { - m = stack[i]; - if (is_endless_head (m, n)) { - res_index = smallest_dfn_pred (m, get_irn_dfn(m) + 1); - if (res_index == -2) /* no smallest dfn pred found. */ - res_index = largest_dfn_pred (m); - break; - } - if (m == n) { break; } /* It's not an unreachable loop, either. */ + m = stack[i]; + if (is_endless_head (m, n)) { + res_index = smallest_dfn_pred (m, get_irn_dfn(m) + 1); + if (res_index == -2) /* no smallest dfn pred found. */ + res_index = largest_dfn_pred (m); + break; + } + if (m == n) { break; } /* It's not an unreachable loop, either. */ } //assert(0 && "no head found on stack"); } @@ -851,26 +833,24 @@ int search_endproj_in_stack(ir_node *start_block) assert(is_Block(start_block)); for(i = tos - 1; i >= 0; --i) { - DDMN(stack[i]); if(get_irn_op(stack[i]) == op_Proj && get_irn_mode(stack[i]) == mode_X && - get_irn_op(get_irn_n(stack[i], 0)) == op_EndReg) - { - printf("FOUND PROJ!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - ir_node *end_projx = stack[i]; - - int arity = get_irn_arity(start_block); - for(j = 0; j < arity; j++) - { - ir_node *begin_projx = get_Block_cfgpred(get_irg_start_block(get_irn_irg(end_projx)), - get_Proj_proj(end_projx)); - DDMN(begin_projx); - if(get_irn_n(start_block, j) == begin_projx) - { - printf("FOUND IT!!!!!!!!!!!!!!!!!!\n"); - return(j); - } - } - } + get_irn_op(get_irn_n(stack[i], 0)) == op_EndReg) + { + printf("FOUND PROJ!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + ir_node *end_projx = stack[i]; + + int arity = get_irn_arity(start_block); + for(j = 0; j < arity; j++) + { + ir_node *begin_projx = get_Block_cfgpred(get_irg_start_block(get_irn_irg(end_projx)), + get_Proj_proj(end_projx)); + if(get_irn_n(start_block, j) == begin_projx) + { + printf("FOUND IT!!!!!!!!!!!!!!!!!!\n"); + return(j); + } + } + } } return(-1); } @@ -885,10 +865,7 @@ void link_to_reg_end (ir_node *n, void *env) { /* Reg End Projx -> Find the CallBegin Projx and hash it */ ir_node *end_projx = n; ir_node *begin_projx = get_Block_cfgpred(get_irg_start_block(get_irn_irg(end_projx)), - get_Proj_proj(end_projx)); - printf("Linked the following ProjxNodes:\n"); - DDMN(begin_projx); - DDMN(end_projx); + get_Proj_proj(end_projx)); set_projx_link(begin_projx, end_projx); } } @@ -943,10 +920,10 @@ static void scc (ir_node *n) { /* if ((!m) || (get_irn_op(m) == op_Unknown)) continue; */ scc (m); if (irn_is_in_stack(m)) { - /* Uplink of m is smaller if n->m is a backedge. - Propagate the uplink to mark the loop. */ - if (get_irn_uplink(m) < get_irn_uplink(n)) - set_irn_uplink(n, get_irn_uplink(m)); + /* Uplink of m is smaller if n->m is a backedge. + Propagate the uplink to mark the loop. */ + if (get_irn_uplink(m) < get_irn_uplink(n)) + set_irn_uplink(n, get_irn_uplink(m)); } } } @@ -966,9 +943,9 @@ static void scc (ir_node *n) { ir_node *tail = find_tail(n); if (tail) { /* We have a loop, that is no straight line code, - because we found a loop head! - Next actions: Open a new loop on the loop tree and - try to find inner loops */ + because we found a loop head! + Next actions: Open a new loop on the loop tree and + try to find inner loops */ #if NO_LOOPS_WITHOUT_HEAD /* This is an adaption of the algorithm from fiasco / optscc to @@ -984,11 +961,11 @@ static void scc (ir_node *n) { ir_loop *l; int close; if ((get_loop_n_elements(current_loop) > 0) || (is_outermost_loop(current_loop))) { - l = new_loop(); - close = 1; + l = new_loop(); + close = 1; } else { - l = current_loop; - close = 0; + l = current_loop; + close = 0; } #else ir_loop *l = new_loop(); @@ -998,21 +975,21 @@ static void scc (ir_node *n) { pop_scc_unmark_visit (n); /* The current backedge has been marked, that is temporarily eliminated, - by find tail. Start the scc algorithm - anew on the subgraph that is left (the current loop without the backedge) - in order to find more inner loops. */ + by find tail. Start the scc algorithm + anew on the subgraph that is left (the current loop without the backedge) + in order to find more inner loops. */ scc (tail); assert (irn_visited(n)); #if NO_LOOPS_WITHOUT_HEAD if (close) #endif - close_loop(l); + close_loop(l); } else - { - /* No loop head was found, that is we have straightline code. - Pop all nodes from the stack to the current loop. */ + { + /* No loop head was found, that is we have straightline code. + Pop all nodes from the stack to the current loop. */ pop_scc_to_loop(n); } } @@ -1044,10 +1021,10 @@ static void my_scc (ir_node *n) { /* if ((!m) || (get_irn_op(m) == op_Unknown)) continue; */ my_scc (m); if (irn_is_in_stack(m)) { - /* Uplink of m is smaller if n->m is a backedge. - Propagate the uplink to mark the loop. */ - if (get_irn_uplink(m) < get_irn_uplink(n)) - set_irn_uplink(n, get_irn_uplink(m)); + /* Uplink of m is smaller if n->m is a backedge. + Propagate the uplink to mark the loop. */ + if (get_irn_uplink(m) < get_irn_uplink(n)) + set_irn_uplink(n, get_irn_uplink(m)); } } } @@ -1067,9 +1044,9 @@ static void my_scc (ir_node *n) { ir_node *tail = find_tail(n); if (tail) { /* We have a loop, that is no straight line code, - because we found a loop head! - Next actions: Open a new loop on the loop tree and - try to find inner loops */ + because we found a loop head! + Next actions: Open a new loop on the loop tree and + try to find inner loops */ #if NO_LOOPS_WITHOUT_HEAD /* This is an adaption of the algorithm from fiasco / optscc to @@ -1082,11 +1059,11 @@ static void my_scc (ir_node *n) { ir_loop *l; int close; if ((get_loop_n_elements(current_loop) > 0) || (is_outermost_loop(current_loop))) { - l = new_loop(); - close = 1; + l = new_loop(); + close = 1; } else { - l = current_loop; - close = 0; + l = current_loop; + close = 0; } #else ir_loop *l = new_loop(); @@ -1096,21 +1073,21 @@ static void my_scc (ir_node *n) { pop_scc_unmark_visit (n); /* The current backedge has been marked, that is temporarily eliminated, - by find tail. Start the scc algorithm - anew on the subgraph that is left (the current loop without the backedge) - in order to find more inner loops. */ + by find tail. Start the scc algorithm + anew on the subgraph that is left (the current loop without the backedge) + in order to find more inner loops. */ my_scc (tail); assert (irn_visited(n)); #if NO_LOOPS_WITHOUT_HEAD if (close) #endif - close_loop(l); + close_loop(l); } else - { - /* No loop head was found, that is we have straightline code. - Pop all nodes from the stack to the current loop. */ + { + /* No loop head was found, that is we have straightline code. + Pop all nodes from the stack to the current loop. */ pop_scc_to_loop(n); } } @@ -1158,6 +1135,7 @@ int construct_backedges(ir_graph *irg) { } +#ifdef INTERPROCEDURAL_VIEW int construct_ip_backedges (void) { ir_graph *rem = current_ir_graph; int rem_ipv = get_interprocedural_view(); @@ -1172,7 +1150,7 @@ int construct_ip_backedges (void) { current_loop = NULL; new_loop(); /* sets current_loop */ - set_interprocedural_view(true); + set_interprocedural_view(1); inc_max_irg_visited(); for (i = 0; i < get_irp_n_irgs(); i++) @@ -1241,7 +1219,7 @@ void my_construct_ip_backedges (void) { current_loop = NULL; new_loop(); /* sets current_loop */ - set_interprocedural_view(true); + set_interprocedural_view(1); inc_max_irg_visited(); for (i = 0; i < get_irp_n_irgs(); i++) @@ -1295,16 +1273,21 @@ void my_construct_ip_backedges (void) { current_ir_graph = rem; set_interprocedural_view(rem_ipv); } +#endif static void reset_backedges(ir_node *n) { if (is_possible_loop_head(n)) { +#ifdef INTERPROCEDURAL_VIEW int rem = get_interprocedural_view(); - set_interprocedural_view(true); + set_interprocedural_view(1); clear_backedges(n); - set_interprocedural_view(true); + set_interprocedural_view(1); clear_backedges(n); set_interprocedural_view(rem); +#else + clear_backedges(n); +#endif } } @@ -1322,6 +1305,7 @@ static void loop_reset_backedges(ir_loop *l) { */ static void loop_reset_node(ir_node *n, void *env) { + (void) env; set_irn_loop(n, NULL); reset_backedges(n); } @@ -1344,12 +1328,16 @@ void free_loop_information(ir_graph *irg) { void free_all_loop_information (void) { int i; +#ifdef INTERPROCEDURAL_VIEW int rem = get_interprocedural_view(); - set_interprocedural_view(true); /* To visit all filter nodes */ + set_interprocedural_view(1); /* To visit all filter nodes */ +#endif for (i = 0; i < get_irp_n_irgs(); i++) { free_loop_information(get_irp_irg(i)); } +#ifdef INTERPROCEDURAL_VIEW set_interprocedural_view(rem); +#endif } @@ -1365,7 +1353,6 @@ static int test_loop_node(ir_loop *l) { assert(l && l->kind == k_ir_loop); if (get_loop_n_elements(l) == 0) { - printf(" Loop completely empty! "); DDML(l); found_problem = 1; dump_loop(l, "-ha"); } @@ -1373,24 +1360,18 @@ static int test_loop_node(ir_loop *l) { le = get_loop_element(l, 0); if (*(le.kind) != k_ir_node) { assert(le.kind && *(le.kind) == k_ir_loop); - printf(" First loop element is not a node! "); DDML(l); - printf(" "); DDML(le.son); found_problem = 1; dump_loop(l, "-ha"); } if ((*(le.kind) == k_ir_node) && !is_possible_loop_head(le.node)) { - printf(" Wrong node as head! "); DDML(l); - printf(" "); DDMN(le.node); found_problem = 1; dump_loop(l, "-ha"); } if ((get_loop_depth(l) != 0) && (*(le.kind) == k_ir_node) && !has_backedges(le.node)) { - printf(" Loop head has no backedges! "); DDML(l); - printf(" "); DDMN(le.node); found_problem = 1; dump_loop(l, "-ha"); } @@ -1406,7 +1387,6 @@ static int test_loop_node(ir_loop *l) { } if (has_node == 0) { - printf(" Loop has no firm node! "); DDML(l); found_problem = 1; dump_loop(l, "-ha"); } @@ -1420,7 +1400,6 @@ static int test_loop_node(ir_loop *l) { */ void find_strange_loop_nodes(ir_loop *l) { int found_problem = 0; - printf("\nTesting loop "); DDML(l); found_problem = test_loop_node(l); printf("Finished Test\n\n"); if (found_problem) exit(0); @@ -1434,17 +1413,17 @@ void find_strange_loop_nodes(ir_loop *l) { int is_loop_variant(ir_loop *l, ir_loop *b) { int i, n_elems; - if (l == b) return true; + if (l == b) return 1; n_elems = get_loop_n_elements(l); for (i = 0; i < n_elems; ++i) { loop_element e = get_loop_element(l, i); if (is_ir_loop(e.kind)) if (is_loop_variant(e.son, b)) - return true; + return 1; } - return false; + return 0; } /* Test whether a value is loop invariant. @@ -1453,7 +1432,7 @@ int is_loop_variant(ir_loop *l, ir_loop *b) { * @param block A block node. We pass the block, not the loop as we must * start off with a block loop to find all proper uses. * - * Returns true, if the node n is not changed in the loop block + * Returns non-zero, if the node n is not changed in the loop block * belongs to or in inner loops of this blocks loop. */ int is_loop_invariant(ir_node *n, ir_node *block) { ir_loop *l = get_irn_loop(block);