ia32: Simplify ia32_register_saved_by().
[libfirm] / ir / be / ia32 / ia32_address_mode.c
index 5e2aea2..6d72e33 100644 (file)
@@ -22,7 +22,6 @@
  * @brief       This file contains functions for matching firm graphs for
  *              nodes that can be used as address mode for x86 instructions
  * @author      Matthias Braun
- * @version     $Id$
  */
 #include "config.h"
 
@@ -36,8 +35,8 @@
 #include "iredges_t.h"
 #include "irgwalk.h"
 
-#include "../benode.h"
-#include "../belive.h"
+#include "benode.h"
+#include "belive.h"
 
 #define AGGRESSIVE_AM
 
@@ -67,7 +66,7 @@ static bool do_is_immediate(const ir_node *node, int *symconsts, bool negate)
 #ifdef DEBUG_libfirm
                        ir_fprintf(stderr,
                                   "Optimisation warning tarval of %+F(%+F) is not a long.\n",
-                                  node, current_ir_graph);
+                                  node, get_irn_irg(node));
 #endif
                        return false;
                }
@@ -418,12 +417,12 @@ int ia32_is_non_address_mode_node(ir_node const *node)
 }
 
 /**
- * Check if a given value is last used (i.e. die after) the block of some other node.
+ * Check if a given value is last used (i.e. die after) the block of some
+ * other node.
  */
 static int value_last_used_here(be_lv_t *lv, ir_node *here, ir_node *value)
 {
-       ir_node         *block = get_nodes_block(here);
-       const ir_edge_t *edge;
+       ir_node *block = get_nodes_block(here);
 
        /* If the value is live end it is for sure it does not die here */
        if (be_is_live_end(lv, block, value)) return 0;
@@ -441,6 +440,12 @@ static int value_last_used_here(be_lv_t *lv, ir_node *here, ir_node *value)
        return 1;
 }
 
+static bool simple_is_immediate(const ir_node *node)
+{
+       int symconsts = 0;
+       return do_is_immediate(node, &symconsts, false);
+}
+
 /**
  * Walker: mark those nodes that cannot be part of an address mode because
  * their value must be accessed through a register
@@ -486,12 +491,17 @@ static void mark_non_address_nodes(ir_node *node, void *env)
                left  = get_binop_left(node);
                right = get_binop_right(node);
 
-               /* Fold AM if any of the two operands does not die here.  This duplicates
+               /* if any of the operands is an immediate then this will not
+                * increase register pressure */
+               if (simple_is_immediate(left) || simple_is_immediate(right))
+                       return;
+
+               /* Fold AM if any of the two operands does not die here. This duplicates
                 * an addition and has the same register pressure for the case that only
                 * one operand dies, but is faster (on Pentium 4).
                 * && instead of || only folds AM if both operands do not die here */
                if (!value_last_used_here(lv, node, left) ||
-                               !value_last_used_here(lv, node, right)) {
+                   !value_last_used_here(lv, node, right)) {
                        return;
                }
 
@@ -514,7 +524,10 @@ static void mark_non_address_nodes(ir_node *node, void *env)
 
 void ia32_calculate_non_address_mode_nodes(ir_graph *irg)
 {
-       be_lv_t  *lv  = be_assure_liveness(irg);
+       be_lv_t *lv;
+
+       be_assure_live_chk(irg);
+       lv = be_get_irg_liveness(irg);
 
        non_address_mode_nodes = bitset_malloc(get_irg_last_idx(irg));