an old floating point benchmark
[libfirm] / ir / be / bespillremat.c
index 6c36247..d9d309f 100644 (file)
 
 #include "bechordal_t.h"
 
-#define BIGM 100000.0
-
-#define DUMP_SOLUTION
-#define DUMP_ILP
+//#define DUMP_SOLUTION
+//#define DUMP_ILP
 //#define KEEPALIVE /* keep alive all inserted remats and dump graph with remats */
 #define COLLECT_REMATS /* enable rematerialization */
 #define COLLECT_INVERSE_REMATS /* enable placement of inverse remats */
+//#define ONLY_BRIGGS_REMATS /* only remats without parameters (or only with ignored params) */
 #define REMAT_WHILE_LIVE /* only remat values that are live */
 //#define NO_ENLARGE_L1V3N355 /* do not remat after the death of some operand */
 //#define EXECFREQ_LOOPDEPH /* compute execution frequency from loop depth only */
@@ -506,6 +505,7 @@ add_remat(const spill_ilp_t * si, const remat_t * remat)
        }
 }
 
+#ifdef NO_SINGLE_USE_REMATS
 static int
 get_irn_n_nonremat_edges(const spill_ilp_t * si, const ir_node * irn)
 {
@@ -521,6 +521,22 @@ get_irn_n_nonremat_edges(const spill_ilp_t * si, const ir_node * irn)
 
        return i;
 }
+#endif
+
+#ifdef ONLY_BRIGGS_REMATS
+static int
+get_irn_n_nonignore_args(const spill_ilp_t * si, const ir_node * irn)
+{
+       int n;
+       unsigned int ret = 0;
+
+       for(n=get_irn_arity(irn)-1; n>=0; --n) {
+               if(has_reg_class(si, irn)) ++ret;
+       }
+
+       return ret;
+}
+#endif
 
 static INLINE void
 get_remats_from_op(spill_ilp_t * si, const ir_node * op)
@@ -528,18 +544,21 @@ get_remats_from_op(spill_ilp_t * si, const ir_node * op)
        int      n;
        remat_t *remat;
 
+       if( has_reg_class(si, op)
 #ifdef NO_SINGLE_USE_REMATS
-       if(has_reg_class(si, op) && (get_irn_n_nonremat_edges(si, op) > 1)) {
-#else
-       if(has_reg_class(si, op)) {
+       && (get_irn_n_nonremat_edges(si, op) > 1)
+#endif
+#ifdef ONLY_BRIGGS_REMATS
+       && (get_irn_n_nonignore_args(si, op) == 0)
 #endif
+       ) {
                remat = get_remat_from_op(si, op, op);
                if(remat) {
                        add_remat(si, remat);
                }
        }
 
-#ifdef COLLECT_INVERSE_REMATS
+#if defined(COLLECT_INVERSE_REMATS) && !defined(ONLY_BRIGGS_REMATS)
        /* repeat the whole stuff for each remat retrieved by get_remat_from_op(op, arg)
           for each arg */
        for (n = get_irn_arity(op)-1; n>=0; --n) {
@@ -3034,7 +3053,7 @@ connect_all_spills_with_keep(spill_ilp_t * si)
 }
 
 /** insert a spill at an arbitrary position */
-ir_node *be_spill2(const arch_env_t *arch_env, ir_node *irn, ir_node *insert, ir_node *ctx)
+ir_node *be_spill2(const arch_env_t *arch_env, ir_node *irn, ir_node *insert)
 {
        ir_node *bl     = is_Block(insert)?insert:get_nodes_block(insert);
        ir_graph *irg   = get_irn_irg(bl);
@@ -3045,7 +3064,7 @@ ir_node *be_spill2(const arch_env_t *arch_env, ir_node *irn, ir_node *insert, ir
        const arch_register_class_t *cls       = arch_get_irn_reg_class(arch_env, irn, -1);
        const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
 
-       spill = be_new_Spill(cls, cls_frame, irg, bl, frame, irn, ctx);
+       spill = be_new_Spill(cls, cls_frame, irg, bl, frame, irn);
 
        /*
         * search the right insertion point. a spill of a phi cannot be put
@@ -3231,7 +3250,7 @@ insert_spill(spill_ilp_t * si, ir_node * irn, const ir_node * value, ir_node * b
 
        DBG((si->dbg, LEVEL_3, "\t  inserting spill for value %+F after %+F\n", irn, before));
 
-       spill = be_spill2(arch_env, irn, before, irn);
+       spill = be_spill2(arch_env, irn, before);
 
        defs = set_insert_def(si->values, value);
        assert(defs);
@@ -3469,7 +3488,7 @@ insert_mem_copy(spill_ilp_t * si, ir_node * bb, ir_node * value)
 
        DBG((si->dbg, LEVEL_2, "\t  inserting mem copy for value %+F after %+F\n", value, insert_pos));
 
-       spill = be_spill2(arch_env, is_Block(insert_pos)?value:insert_pos, insert_pos, value);
+       spill = be_spill2(arch_env, is_Block(insert_pos)?value:insert_pos, insert_pos);
 
        return spill;
 }
@@ -3694,7 +3713,7 @@ kill_all_unused_values_in_schedule(spill_ilp_t * si)
        lc_bitset_free(kh.used);
 }
 
-static void
+void
 print_irn_pset(pset * p)
 {
        ir_node   *irn;
@@ -3704,7 +3723,7 @@ print_irn_pset(pset * p)
        }
 }
 
-static void
+void
 dump_phi_class(spill_ilp_t * si, pset * phiclass, const char * file)
 {
     FILE           *f = fopen(file, "w");
@@ -3958,12 +3977,15 @@ walker_spillslotassigner(ir_node * irn, void * data)
        if(!be_is_Spill(irn)) return;
 
        /* set spill context to phi class if it has one ;) */
-
+       (void) cls;
+#if 0
+       // Matze: not needed anymore
        cls = get_phi_class(irn);
        if(cls)
                be_set_Spill_context(irn, cls);
        else
                be_set_Spill_context(irn, irn);
+#endif
 }
 
 
@@ -4074,7 +4096,7 @@ be_spill_remat(const be_chordal_env_t * chordal_env)
 #endif
 
 #ifdef SOLVE
-       DBG((si.dbg, LEVEL_1, "\tSolving %F\n", chordal_env->irg));
+       DBG((si.dbg, LEVEL_1, "\tSolving %s (%d variables, %d constraints)\n", problem_name, si.lpp->var_next, si.lpp->cst_next));
 #ifdef ILP_TIMEOUT
        lpp_set_time_limit(si.lpp, ILP_TIMEOUT);
 #endif