- BugFix: set the ins for the newly created Phis
- BugFix: correctly construct the Phis for old inputs
[r23305]
*/
#include "config.h"
#include "ircons.h"
*/
#include "config.h"
#include "ircons.h"
#include "irgraph_t.h"
#include "irnode_t.h"
#include "iropt_t.h"
#include "irgraph_t.h"
#include "irnode_t.h"
#include "iropt_t.h"
ir_node *irn = node->node;
int i;
ir_node *irn = node->node;
int i;
- DB((dbg, LEVEL_3, " propagate %+F\n", node->node));
+ DB((dbg, LEVEL_3, " propagate %+F\n", irn));
ir_normalize_node(node->node);
for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
ir_node *pred = get_irn_n(irn, i);
ir_normalize_node(node->node);
for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
ir_node *pred = get_irn_n(irn, i);
p_node->is_input = 1;
add_node(bl, p_node);
if (! is_Phi(irn))
p_node->is_input = 1;
add_node(bl, p_node);
if (! is_Phi(irn))
- add_pair(bl, node->node, i, env);
+ add_pair(bl, irn, i, env);
} else if (! irn_visited_else_mark(pred)) {
/* not yet visited, ok */
p_node = create_node(pred, env);
} else if (! irn_visited_else_mark(pred)) {
/* not yet visited, ok */
p_node = create_node(pred, env);
partition_t *part, *next;
list_for_each_entry_safe(partition_t, part, next, &env->partitions, part_list) {
partition_t *part, *next;
list_for_each_entry_safe(partition_t, part, next, &env->partitions, part_list) {
- if (part->n_blocks == 1) {
- /* only one block left, move to ready */
+ if (part->n_blocks < 2) {
+ /* zero or one block left, kill this partition */
list_del(&part->part_list);
list_del(&part->part_list);
- DB((dbg, LEVEL_1, "Partition %u contains only one block, killed\n", part->nr));
+ DB((dbg, LEVEL_1, "Partition %u contains less than 2 blocks, killed\n", part->nr));
} else
propagate_blocks(part, env);
}
} else
propagate_blocks(part, env);
}
n = get_Block_n_cfgpreds(block);
ins = NEW_ARR_F(ir_node *, n);
n = get_Block_n_cfgpreds(block);
ins = NEW_ARR_F(ir_node *, n);
- for (i = 0; i < n; ++i)
+ for (i = 0; i < n; ++i) {
ins[i] = get_Block_cfgpred(block, i);
ins[i] = get_Block_cfgpred(block, i);
/* ... for all existing Phis ... */
for (repr_phi = repr->phis; repr_phi != NULL; repr_phi = repr_phi->next) {
repr_phi->ins = NEW_ARR_F(ir_node *, n);
for (i = 0; i < n; ++i)
/* ... for all existing Phis ... */
for (repr_phi = repr->phis; repr_phi != NULL; repr_phi = repr_phi->next) {
repr_phi->ins = NEW_ARR_F(ir_node *, n);
for (i = 0; i < n; ++i)
- ins[i] = get_Phi_pred(repr_phi->phi, i);
+ repr_phi->ins[i] = get_Phi_pred(repr_phi->phi, i);
}
/* ... and all newly created Phis */
for (repr_pair = repr->input_pairs; repr_pair != NULL; repr_pair = repr_pair->next) {
}
/* ... and all newly created Phis */
for (repr_pair = repr->input_pairs; repr_pair != NULL; repr_pair = repr_pair->next) {
- repr_pair->ins = NEW_ARR_F(ir_node *, part->n_blocks);
- repr_pair->ins[0] = get_irn_n(repr_pair->irn, repr_pair->index);
+ ir_node *input = get_irn_n(repr_pair->irn, repr_pair->index);
+
+ repr_pair->ins = NEW_ARR_F(ir_node *, n);
+ for (i = 0; i < n; ++i)
+ repr_pair->ins[i] = input;
}
/* collect new in arrays */
}
/* collect new in arrays */
/* second step: update control flow */
n = get_Block_n_cfgpreds(block);
for (i = 0; i < n; ++i) {
/* second step: update control flow */
n = get_Block_n_cfgpreds(block);
for (i = 0; i < n; ++i) {
- ARR_APP1(ir_node *, ins, get_Block_cfgpred(block, i));
+ ir_node *pred = get_Block_cfgpred(block, i);
+ ARR_APP1(ir_node *, ins, pred);
}
/* third step: update Phis */
for (repr_phi = repr->phis, phi = bl->phis;
repr_phi != NULL;
repr_phi = repr_phi->next, phi = phi->next) {
}
/* third step: update Phis */
for (repr_phi = repr->phis, phi = bl->phis;
repr_phi != NULL;
repr_phi = repr_phi->next, phi = phi->next) {
- for (i = 0; i < n; ++i)
- ARR_APP1(ir_node *, repr_phi->ins, get_Phi_pred(phi->phi, i));
+ for (i = 0; i < n; ++i) {
+ ir_node *pred = get_Phi_pred(phi->phi, i);
+ ARR_APP1(ir_node *, repr_phi->ins, pred);
+ }
}
/* fourth step: update inputs for new Phis */
for (repr_pair = repr->input_pairs, pair = bl->input_pairs;
repr_pair != NULL;
repr_pair = repr_pair->next, pair = pair->next) {
}
/* fourth step: update inputs for new Phis */
for (repr_pair = repr->input_pairs, pair = bl->input_pairs;
repr_pair != NULL;
repr_pair = repr_pair->next, pair = pair->next) {
- repr_pair->ins[block_nr] = get_irn_n(pair->irn, pair->index);
+ ir_node *input = get_irn_n(pair->irn, pair->index);
+
+ for (i = 0; i < n; ++i)
+ ARR_APP1(ir_node *, repr_pair->ins, input);
}
/* ... and all inputs by creating new Phis ... */
}
/* ... and all inputs by creating new Phis ... */
for (repr_pair = repr->input_pairs; repr_pair != NULL; repr_pair = repr_pair->next) {
ir_node *input = get_irn_n(repr_pair->irn, repr_pair->index);
ir_mode *mode = get_irn_mode(input);
for (repr_pair = repr->input_pairs; repr_pair != NULL; repr_pair = repr_pair->next) {
ir_node *input = get_irn_n(repr_pair->irn, repr_pair->index);
ir_mode *mode = get_irn_mode(input);