* @author Christoph Mallon
* @version $Id: $
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include "iroptimize.h"
-#include "array.h"
+#include "array_t.h"
#include "debug.h"
#include "ircons.h"
#include "irgraph.h"
} else if (is_Store(other)) {
other_addr = get_Store_ptr(other);
} else {
- return may_alias;
+ return ir_may_alias;
}
other_mode = get_irn_mode(other);
}
+static int in_cmp(void const* va, void const* vb)
+{
+ ir_node const* const a = *(ir_node const*const*)va;
+ ir_node const* const b = *(ir_node const*const*)vb;
+ return get_irn_idx(a) - get_irn_idx(b);
+}
+
+
static ir_node* GenerateSync(ir_graph* irg, ir_node* block, ir_nodeset_t* after_set)
{
size_t set_size = ir_nodeset_size(after_set);
for (i = 0; i < set_size; i++) {
in[i] = ir_nodeset_iterator_next(&iter);
}
+ qsort(in, set_size, sizeof(*in), in_cmp);
return new_r_Sync(irg, block, set_size, in);
}
}
ir_alias_relation rel = get_alias_relation(irg, addr, mode, other_addr, other_mode);
DB((dbg, LEVEL_3, "===> Testing for alias between %+F and %+F. Relation is %d\n", addr, other_addr, rel));
- if (rel == no_alias) {
+ if (rel == ir_no_alias) {
continue;
}
DB((dbg, LEVEL_3, "===> %+F potentially aliases address %+F\n", load, other_addr));
ir_node* other_node;
DB((dbg, LEVEL_3, "===> Testing for alias between %+F and %+F. Relation is %d\n", addr, other_addr, rel));
- if (rel == no_alias) {
+ if (rel == ir_no_alias) {
continue;
}
DB((dbg, LEVEL_3, "===> %+F potentially aliases address %+F\n", store, other_addr));
ir_nodeset_iterator_init(&interfere_iter, &interfere_sets[i]);
while ((other_node = ir_nodeset_iterator_next(&interfere_iter)) != NULL) {
- if (AliasTest(irg, addr, mode, other_node) != no_alias) {
+ if (AliasTest(irg, addr, mode, other_node) != ir_no_alias) {
DB((dbg, LEVEL_3, "===> Removing %+F from execute-after set of %+F due to %+F\n", other_node, addrs[i], store));
ir_nodeset_remove_iterator(&interfere_sets[i], &interfere_iter);
}
if (block != last_block) {
DB((dbg, LEVEL_3, "===> Changing block from %+F to %+F\n", last_block, block));
block_change = 1;
- if (Block_not_block_visited(block)) {
+ if (!Block_block_visited(block)) {
mark_Block_block_visited(block);
} else {
DB((dbg, LEVEL_2, "===> Hit already visited block at %+F\n", node));
ir_node* unknown;
DB((dbg, LEVEL_3, "===> The predecessor was not finished yet\n"));
- assert(!Block_not_block_visited(pred_block));
+ assert(Block_block_visited(pred_block));
unknown = new_r_Unknown(irg, mode_M);
for (i = 0; i < count_addrs; i++) {
size_t npreds = get_Block_n_cfgpreds(end_block);
size_t i;
- unfinished_phis = xmalloc(sizeof(*unfinished_phis) * count_addrs);
+ unfinished_phis = XMALLOCN(ir_node, count_addrs);
for (i = 0; i < count_addrs; i++) {
unfinished_phis[i] = NULL;
}
}
}
-
+#if 0
static void NormaliseSync(ir_node* node, void* env)
{
ir_nodeset_t preds;
ir_nodeset_destroy(&preds);
}
-
-#if 0
void opt_ldst2(ir_graph* irg)
{
FIRM_DBG_REGISTER(dbg, "firm.opt.ldst2");
static void parallelise_load(parallelise_info *pi, ir_node *irn)
{
+ /* There is no point in investigating the same subgraph twice */
+ if (ir_nodeset_contains(&pi->user_mem, irn))
+ return;
+
//ir_fprintf(stderr, "considering %+F\n", irn);
if (get_nodes_block(irn) == pi->origin_block) {
if (is_Proj(irn)) {
ir_node *org_ptr = pi->origin_ptr;
ir_mode *store_mode = get_irn_mode(get_Store_value(pred));
ir_node *store_ptr = get_Store_ptr(pred);
- if (get_alias_relation(current_ir_graph, org_ptr, org_mode, store_ptr, store_mode) == no_alias) {
+ if (get_alias_relation(current_ir_graph, org_ptr, org_mode, store_ptr, store_mode) == ir_no_alias) {
ir_node *mem = get_Store_mem(pred);
- ir_fprintf(stderr, "Ld after St: %+F (%+F) does not alias %+F (%+F)\n", org_ptr, org_mode, store_ptr, store_mode);
+ //ir_fprintf(stderr, "Ld after St: %+F (%+F) does not alias %+F (%+F)\n", org_ptr, org_mode, store_ptr, store_mode);
ir_nodeset_insert(&pi->user_mem, irn);
//ir_fprintf(stderr, "adding %+F to user set\n", irn);
parallelise_load(pi, mem);
static void parallelise_store(parallelise_info *pi, ir_node *irn)
{
+ /* There is no point in investigating the same subgraph twice */
+ if (ir_nodeset_contains(&pi->user_mem, irn))
+ return;
+
//ir_fprintf(stderr, "considering %+F\n", irn);
if (get_nodes_block(irn) == pi->origin_block) {
if (is_Proj(irn)) {
ir_node *org_ptr = pi->origin_ptr;
ir_mode *load_mode = get_Load_mode(pred);
ir_node *load_ptr = get_Load_ptr(pred);
- if (get_alias_relation(current_ir_graph, org_ptr, org_mode, load_ptr, load_mode) == no_alias) {
+ if (get_alias_relation(current_ir_graph, org_ptr, org_mode, load_ptr, load_mode) == ir_no_alias) {
ir_node *mem = get_Load_mem(pred);
- ir_fprintf(stderr, "St after Ld: %+F (%+F) does not alias %+F (%+F)\n", org_ptr, org_mode, load_ptr, load_mode);
+ //ir_fprintf(stderr, "St after Ld: %+F (%+F) does not alias %+F (%+F)\n", org_ptr, org_mode, load_ptr, load_mode);
ir_nodeset_insert(&pi->user_mem, irn);
//ir_fprintf(stderr, "adding %+F to user set\n", irn);
parallelise_store(pi, mem);
ir_node *org_ptr = pi->origin_ptr;
ir_mode *store_mode = get_irn_mode(get_Store_value(pred));
ir_node *store_ptr = get_Store_ptr(pred);
- if (get_alias_relation(current_ir_graph, org_ptr, org_mode, store_ptr, store_mode) == no_alias) {
+ if (get_alias_relation(current_ir_graph, org_ptr, org_mode, store_ptr, store_mode) == ir_no_alias) {
ir_node *mem;
- ir_fprintf(stderr, "St after St: %+F (%+F) does not alias %+F (%+F)\n", org_ptr, org_mode, store_ptr, store_mode);
+ //ir_fprintf(stderr, "St after St: %+F (%+F) does not alias %+F (%+F)\n", org_ptr, org_mode, store_ptr, store_mode);
ir_nodeset_insert(&pi->user_mem, irn);
//ir_fprintf(stderr, "adding %+F to user set\n", irn);
mem = get_Store_mem(pred);
}
n = ir_nodeset_size(&pi.user_mem);
- if (n != 0) { /* nothing happend otherwise */
+ if (n != 0) { /* nothing happened otherwise */
ir_graph *irg = current_ir_graph;
ir_node *sync;
ir_node **in;
}
-void opt_ldst2(ir_graph *irg)
+void opt_sync(ir_graph *irg)
{
- assure_irg_address_taken_computed(irg);
- assure_irp_globals_address_taken_computed();
+ //assure_irg_entity_usage_computed(irg);
+ //assure_irp_globals_entity_usage_computed();
irg_walk_graph(irg, NULL, walker, NULL);
- //optimize_graph_df(irg);
+ //optimize_graph_df(irg);
//irg_walk_graph(irg, NormaliseSync, NULL, NULL);
}