Renamed is_Div_remainderless to get_Div_no_remainder
[libfirm] / ir / opt / boolopt.c
index 45289d4..08168a8 100644 (file)
@@ -1,3 +1,30 @@
+/*
+ * Copyright (C) 1995-2008 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   boolean condition/controlflow optimisations
+ * @author  Matthias Braun, Christoph Mallon
+ * @version $Id: cfopt.c 22579 2008-10-07 14:54:04Z beck $
+ */
+#include "config.h"
+
 #include <assert.h>
 #include <string.h>
 
@@ -90,7 +117,7 @@ static ir_node *bool_and(cond_pair* const cpair)
        if ((pnc_lo == pn_Cmp_Lt || pnc_lo == pn_Cmp_Le || pnc_lo == pn_Cmp_Eq) &&
                        (pnc_hi == pn_Cmp_Eq || pnc_hi == pn_Cmp_Ge || pnc_hi == pn_Cmp_Gt)) {
                /* x <|<=|== lo | x ==|>=|> hi -> false */
-               ir_node *const t = new_Const(mode_b, tarval_b_false);
+               ir_node *const t = new_Const(tarval_b_false);
                return t;
        } else if ((pnc_lo == pn_Cmp_Lt || pnc_lo == pn_Cmp_Le || pnc_lo == pn_Cmp_Eq) &&
                                                 (pnc_hi == pn_Cmp_Lt || pnc_hi == pn_Cmp_Le || pnc_hi == pn_Cmp_Lg)) {
@@ -116,7 +143,7 @@ static ir_node *bool_and(cond_pair* const cpair)
                                return p;
                        } else if (pnc_hi == pn_Cmp_Lt) {
                                /* x > c || x < c + 1 -> false */
-                               ir_node *const t = new_Const(mode_b, tarval_b_false);
+                               ir_node *const t = new_Const(tarval_b_false);
                                return t;
                        } else if (pnc_hi == pn_Cmp_Le) {
                                /* x > c || x <= c + 1 -> x != c + 1 */
@@ -151,7 +178,7 @@ static ir_node *bool_or(cond_pair *const cpair)
        if ((pnc_lo == pn_Cmp_Ge || pnc_lo == pn_Cmp_Gt || pnc_lo == pn_Cmp_Lg) &&
                        (pnc_hi == pn_Cmp_Lt || pnc_hi == pn_Cmp_Le || pnc_hi == pn_Cmp_Lg)) {
                /* x >=|>|!= lo | x <|<=|!= hi -> true */
-               ir_node *const t = new_Const(mode_b, tarval_b_true);
+               ir_node *const t = new_Const(tarval_b_true);
                return t;
        } else if ((pnc_lo == pn_Cmp_Lt || pnc_lo == pn_Cmp_Le || pnc_lo == pn_Cmp_Eq) &&
                                                 (pnc_hi == pn_Cmp_Lt || pnc_hi == pn_Cmp_Le || pnc_hi == pn_Cmp_Lg)) {
@@ -177,7 +204,7 @@ static ir_node *bool_or(cond_pair *const cpair)
                                return p;
                        } else if (pnc_hi == pn_Cmp_Ge) {
                                /* x <= c || x >= c + 1 -> true */
-                               ir_node *const t = new_Const(mode_b, tarval_b_true);
+                               ir_node *const t = new_Const(tarval_b_true);
                                return t;
                        } else if (pnc_hi == pn_Cmp_Gt) {
                                /* x <= c || x > c + 1 -> x != c + 1 */
@@ -187,7 +214,7 @@ static ir_node *bool_or(cond_pair *const cpair)
                                return p;
                        }
                } else if (pnc_lo == pn_Cmp_Eq && pnc_hi == pn_Cmp_Ge) {
-                       /* x == c || c >= c + 1 -> x >= c */
+                       /* x == c || x >= c + 1 -> x >= c */
                        ir_graph *const irg   = current_ir_graph;
                        ir_node  *const block = get_nodes_block(cmp_lo);
                        ir_node  *const p     = new_r_Proj(irg, block, cmp_lo, mode_b, pn_Cmp_Ge);
@@ -426,7 +453,7 @@ void opt_bool(ir_graph *const irg)
 {
        irg_walk_graph(irg, NULL, bool_walk, NULL);
 
-       ir_reserve_resources(irg, IR_RESOURCE_BLOCK_MARK);
+       ir_reserve_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
 
        irg_walk_graph(irg, clear_block_infos, collect_phis, NULL);
 
@@ -437,5 +464,5 @@ void opt_bool(ir_graph *const irg)
        set_irg_extblk_inconsistent(irg);
        set_irg_loopinfo_inconsistent(irg);
 
-       ir_free_resources(irg, IR_RESOURCE_BLOCK_MARK);
+       ir_free_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
 }