projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added users for symconst.
[libfirm]
/
ir
/
opt
/
opt_osr.c
diff --git
a/ir/opt/opt_osr.c
b/ir/opt/opt_osr.c
index
43734a1
..
3253615
100644
(file)
--- a/
ir/opt/opt_osr.c
+++ b/
ir/opt/opt_osr.c
@@
-53,6
+53,7
@@
#include "array.h"
#include "firmstat.h"
#include "xmalloc.h"
#include "array.h"
#include "firmstat.h"
#include "xmalloc.h"
+#include "error.h"
/** The debug handle. */
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
/** The debug handle. */
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
@@
-305,7
+306,7
@@
static ir_node *do_apply(ir_opcode code, dbg_info *db, ir_node *op1, ir_node *op
result = new_rd_Sub(db, irg, block, op1, op2, mode);
break;
default:
result = new_rd_Sub(db, irg, block, op1, op2, mode);
break;
default:
-
assert(0
);
+
panic("Unsupported opcode"
);
result = NULL;
}
return result;
result = NULL;
}
return result;
@@
-322,24
+323,25
@@
static ir_node *do_apply(ir_opcode code, dbg_info *db, ir_node *op1, ir_node *op
*
* @return the newly created node
*/
*
* @return the newly created node
*/
-static ir_node *apply(ir_node *orig, ir_node *op1, ir_node *op2, iv_env *env) {
+static ir_node *apply(ir_node *
header, ir_node *
orig, ir_node *op1, ir_node *op2, iv_env *env) {
ir_opcode code = get_irn_opcode(orig);
ir_node *result = search(code, op1, op2, env);
ir_opcode code = get_irn_opcode(orig);
ir_node *result = search(code, op1, op2, env);
- if (
! result
) {
+ if (
result == NULL
) {
dbg_info *db = get_irn_dbg_info(orig);
ir_node *op1_header = get_irn_ne(op1, env)->header;
ir_node *op2_header = get_irn_ne(op2, env)->header;
dbg_info *db = get_irn_dbg_info(orig);
ir_node *op1_header = get_irn_ne(op1, env)->header;
ir_node *op2_header = get_irn_ne(op2, env)->header;
- if (op1_header
!= NULL
&& is_rc(op2, op1_header)) {
+ if (op1_header
== header
&& is_rc(op2, op1_header)) {
result = reduce(orig, op1, op2, env);
}
result = reduce(orig, op1, op2, env);
}
- else if (op2_header
!= NULL
&& is_rc(op1, op2_header)) {
+ else if (op2_header
== header
&& is_rc(op1, op2_header)) {
result = reduce(orig, op2, op1, env);
}
else {
result = do_apply(code, db, op1, op2, get_irn_mode(orig));
result = reduce(orig, op2, op1, env);
}
else {
result = do_apply(code, db, op1, op2, get_irn_mode(orig));
- get_irn_ne(result, env)->header = NULL; }
+ get_irn_ne(result, env)->header = NULL;
+ }
}
return result;
}
}
return result;
}
@@
-359,7
+361,7
@@
static ir_node *reduce(ir_node *orig, ir_node *iv, ir_node *rc, iv_env *env) {
ir_opcode code = get_irn_opcode(orig);
ir_node *result = search(code, iv, rc, env);
ir_opcode code = get_irn_opcode(orig);
ir_node *result = search(code, iv, rc, env);
- if (
! result
) {
+ if (
result == NULL
) {
node_entry *e, *iv_e;
int i, n;
ir_mode *mode = get_irn_mode(orig);
node_entry *e, *iv_e;
int i, n;
ir_mode *mode = get_irn_mode(orig);
@@
-390,7
+392,7
@@
static ir_node *reduce(ir_node *orig, ir_node *iv, ir_node *rc, iv_env *env) {
if (e->header == iv_e->header)
o = reduce(orig, o, rc, env);
else if (is_Phi(result) || code == iro_Mul)
if (e->header == iv_e->header)
o = reduce(orig, o, rc, env);
else if (is_Phi(result) || code == iro_Mul)
- o = apply(orig, o, rc, env);
+ o = apply(
iv_e->header,
orig, o, rc, env);
set_irn_n(result, i, o);
}
}
set_irn_n(result, i, o);
}
}
@@
-409,6
+411,7
@@
static void update_scc(ir_node *iv, node_entry *e, iv_env *env) {
ir_node *header = e->header;
waitq *wq = new_waitq();
ir_node *header = e->header;
waitq *wq = new_waitq();
+ DB((dbg, LEVEL_2, " Creating SCC for new an induction variable:\n "));
pscc->head = NULL;
waitq_put(wq, iv);
do {
pscc->head = NULL;
waitq_put(wq, iv);
do {
@@
-419,16
+422,21
@@
static void update_scc(ir_node *iv, node_entry *e, iv_env *env) {
ne->pscc = pscc;
ne->next = pscc->head;
pscc->head = irn;
ne->pscc = pscc;
ne->next = pscc->head;
pscc->head = irn;
+ DB((dbg, LEVEL_2, " %+F,", irn));
for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
ir_node *pred = get_irn_n(irn, i);
node_entry *pe = get_irn_ne(pred, env);
for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
ir_node *pred = get_irn_n(irn, i);
node_entry *pe = get_irn_ne(pred, env);
- if (pe->header == header && pe->pscc == NULL)
+ if (pe->header == header && pe->pscc == NULL) {
+ /* set the pscc here to ensure that the node is NOT enqueued another time */
+ pe->pscc = pscc;
waitq_put(wq, pred);
waitq_put(wq, pred);
+ }
}
} while (! waitq_empty(wq));
del_waitq(wq);
}
} while (! waitq_empty(wq));
del_waitq(wq);
+ DB((dbg, LEVEL_2, "\n"));
}
/**
}
/**
@@
-462,6
+470,7
@@
static int replace(ir_node *irn, ir_node *iv, ir_node *rc, iv_env *env) {
return 0;
}
return 0;
}
+#if 0
/**
* check if a given node is a mul with 2, 4, 8
*/
/**
* check if a given node is a mul with 2, 4, 8
*/
@@
-487,6
+496,7
@@
static int is_x86_shift_const(ir_node *mul) {
}
return 0;
}
}
return 0;
}
+#endif
/**
* Check if an IV represents a counter with constant limits.
/**
* Check if an IV represents a counter with constant limits.
@@
-655,11
+665,6
@@
static int check_replace(ir_node *irn, iv_env *env) {
if (! check_users_for_reg_pressure(iv, env))
return 0;
}
if (! check_users_for_reg_pressure(iv, env))
return 0;
}
- /* check for x86 constants */
- if (env->flags & osr_flag_ignore_x86_shift)
- if (is_x86_shift_const(irn))
- return 0;
-
return replace(irn, iv, rc, env);
}
break;
return replace(irn, iv, rc, env);
}
break;
@@
-993,7
+998,7
@@
static void do_dfs(ir_graph *irg, iv_env *env) {
ir_node *end = get_irg_end(irg);
int i, n;
ir_node *end = get_irg_end(irg);
int i, n;
-
set_using_irn_visited(irg
);
+
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED
);
current_ir_graph = irg;
inc_irg_visited(irg);
current_ir_graph = irg;
inc_irg_visited(irg);
@@
-1010,7
+1015,7
@@
static void do_dfs(ir_graph *irg, iv_env *env) {
dfs(ka, env);
}
dfs(ka, env);
}
-
clear_using_irn_visited(irg
);
+
ir_free_resources(irg, IR_RESOURCE_IRN_VISITED
);
current_ir_graph = rem;
}
current_ir_graph = rem;
}
@@
-1108,12
+1113,12
@@
static ir_node *applyOneEdge(ir_node *iv, ir_node *rc, LFTR_edge *e, iv_env *env
DB((dbg, LEVEL_4, " + %+F", tv_r));
break;
case iro_Sub:
DB((dbg, LEVEL_4, " + %+F", tv_r));
break;
case iro_Sub:
- tv = tarval_sub(tv_l, tv_r);
- tv_init = tarval_sub(tv_init, tv_r);
+ tv = tarval_sub(tv_l, tv_r
, NULL
);
+ tv_init = tarval_sub(tv_init, tv_r
, NULL
);
DB((dbg, LEVEL_4, " - %+F", tv_r));
break;
default:
DB((dbg, LEVEL_4, " - %+F", tv_r));
break;
default:
-
assert(0
);
+
panic("Unsupported opcode"
);
tv = tarval_bad;
}
tv = tarval_bad;
}
@@
-1121,7
+1126,7
@@
static ir_node *applyOneEdge(ir_node *iv, ir_node *rc, LFTR_edge *e, iv_env *env
tv = tarval_add(tv, tv_incr);
} else {
assert(pscc->code == iro_Sub);
tv = tarval_add(tv, tv_incr);
} else {
assert(pscc->code == iro_Sub);
- tv = tarval_sub(tv, tv_incr);
+ tv = tarval_sub(tv, tv_incr
, NULL
);
}
tarval_set_integer_overflow_mode(ovmode);
}
tarval_set_integer_overflow_mode(ovmode);
@@
-1185,7
+1190,7
@@
static void do_lftr(ir_node *cmp, void *ctx) {
ir_node *iv, *rc;
ir_node *nleft = NULL, *nright = NULL;
ir_node *iv, *rc;
ir_node *nleft = NULL, *nright = NULL;
- if (
get_irn_op(cmp) != op_Cmp
)
+ if (
!is_Cmp(cmp)
)
return;
left = get_Cmp_left(cmp);
return;
left = get_Cmp_left(cmp);
@@
-1259,7
+1264,6
@@
void opt_osr(ir_graph *irg, unsigned flags) {
current_ir_graph = irg;
FIRM_DBG_REGISTER(dbg, "firm.opt.osr");
current_ir_graph = irg;
FIRM_DBG_REGISTER(dbg, "firm.opt.osr");
- firm_dbg_set_mask(dbg, -1);
DB((dbg, LEVEL_1, "Doing Operator Strength Reduction for %+F\n", irg));
DB((dbg, LEVEL_1, "Doing Operator Strength Reduction for %+F\n", irg));
@@
-1294,7
+1298,8
@@
void opt_osr(ir_graph *irg, unsigned flags) {
if (env.replaced) {
/* try linear function test replacements */
if (env.replaced) {
/* try linear function test replacements */
- lftr(irg, &env);
+ //lftr(irg, &env); // currently buggy :-(
+ (void) lftr;
set_irg_outs_inconsistent(irg);
DB((dbg, LEVEL_1, "Replacements: %u + %u (lftr)\n\n", env.replaced, env.lftr_replaced));
set_irg_outs_inconsistent(irg);
DB((dbg, LEVEL_1, "Replacements: %u + %u (lftr)\n\n", env.replaced, env.lftr_replaced));