Slimified the bitset implementation a little bit
[libfirm] / ir / ana / height.c
index c067ada..6d3f708 100644 (file)
@@ -1,15 +1,29 @@
 /*
- * Project:     libFIRM
- * File name:   ir/ana/height.c
- * Purpose:     Compute heights of nodes inside basic blocks
- * Author:      Sebastian Hack
- * Modified by:
- * Created:     19.04.2006
- * CVS-ID:      $Id$
- * Copyright:   (c) 2006 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * 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 heights of nodes inside basic blocks
+ * @author   Sebastian Hack
+ * @date     19.04.2006
+ * @version  $Id$
+ */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -71,9 +85,11 @@ static int search(heights_t *h, const ir_node *curr, const ir_node *tgt)
        if(curr == tgt)
                return 1;
 
-       /* If we are in another block we won't find our target. */
+       /* If we are in another block or at a phi we won't find our target. */
        if(get_nodes_block(curr) != get_nodes_block(tgt))
                return 0;
+       if(is_Phi(curr))
+               return 0;
 
        /* Check, if we have already been here. Coming more often won't help :-) */
        h_curr = phase_get_irn_data(&h->ph, curr);
@@ -140,7 +156,7 @@ static unsigned compute_height(heights_t *h, ir_node *irn, const ir_node *bl)
        foreach_out_edge(irn, edge) {
                ir_node *dep = get_edge_src_irn(edge);
 
-               if(!is_Block(dep) && get_nodes_block(dep) == bl) {
+               if(!is_Block(dep) && !is_Phi(dep) && get_nodes_block(dep) == bl) {
                        unsigned dep_height = compute_height(h, dep, bl);
                        ih->height          = MAX(ih->height, dep_height);
                }
@@ -151,6 +167,7 @@ static unsigned compute_height(heights_t *h, ir_node *irn, const ir_node *bl)
        foreach_out_edge_kind(irn, edge, EDGE_KIND_DEP) {
                ir_node *dep = get_edge_src_irn(edge);
 
+               assert(!is_Phi(dep));
                if(!is_Block(dep) && get_nodes_block(dep) == bl) {
                        unsigned dep_height = compute_height(h, dep, bl);
                        ih->height          = MAX(ih->height, dep_height);