+ /* process each spilled node */
+ for (si = set_first(env->spills); si; si = set_next(env->spills)) {
+ reloader_t *rld;
+ ir_node *to_spill = si->to_spill;
+ ir_mode *mode = get_irn_mode(to_spill);
+ ir_node **copies = NEW_ARR_F(ir_node*, 0);
+ double all_remat_costs = 0; /** costs when we would remat all nodes */
+ int force_remat = 0;
+
+ DBG((dbg, LEVEL_1, "\nhandling all reloaders of %+F:\n", to_spill));
+
+ /* determine possibility of rematerialisations */
+ if(be_do_remats) {
+ for (rld = si->reloaders; rld != NULL; rld = rld->next) {
+ double freq;
+ int remat_cost;
+ int remat_cost_delta;
+ ir_node *block;
+ ir_node *reloader = rld->reloader;
+
+ if(rld->rematted_node != NULL) {
+ DBG((dbg, LEVEL_2, "\tforced remat %+F before %+F\n",
+ rld->rematted_node, reloader));
+ continue;
+ }
+ if(rld->remat_cost_delta >= REMAT_COST_INFINITE) {
+ DBG((dbg, LEVEL_2, "\treload before %+F is forbidden\n",
+ reloader));
+ all_remat_costs = REMAT_COST_INFINITE;
+ continue;
+ }
+
+ remat_cost = check_remat_conditions_costs(env, to_spill,
+ reloader, 0);
+ if(remat_cost >= REMAT_COST_INFINITE) {
+ DBG((dbg, LEVEL_2, "\tremat before %+F not possible\n",
+ reloader));
+ rld->remat_cost_delta = REMAT_COST_INFINITE;
+ all_remat_costs = REMAT_COST_INFINITE;
+ continue;
+ }
+
+ remat_cost_delta = remat_cost - env->reload_cost;
+ rld->remat_cost_delta = remat_cost_delta;
+ block = is_Block(reloader) ? reloader : get_nodes_block(reloader);
+ freq = get_block_execfreq(exec_freq, block);
+ all_remat_costs += remat_cost_delta * freq;
+ DBG((dbg, LEVEL_2, "\tremat costs delta before %+F: "
+ "%d (rel %f)\n", reloader, remat_cost_delta,
+ remat_cost_delta * freq));
+ }
+ if(all_remat_costs < REMAT_COST_INFINITE) {
+ ir_node *block = get_nodes_block(to_spill);
+ double freq = get_block_execfreq(exec_freq, block);
+ /* we don't need the costs for the spill if we can remat
+ all reloaders */
+ all_remat_costs -= env->spill_cost * freq;
+
+ DBG((dbg, LEVEL_2, "\tspill costs %d (rel %f)\n",
+ env->spill_cost, env->spill_cost * freq));
+ }