projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove unused variable.
[libfirm]
/
ir
/
opt
/
opt_osr.c
diff --git
a/ir/opt/opt_osr.c
b/ir/opt/opt_osr.c
index
43734a1
..
54e6921
100644
(file)
--- a/
ir/opt/opt_osr.c
+++ b/
ir/opt/opt_osr.c
@@
-28,9
+28,7
@@
* by Keith D. Cooper, L. Taylor Simpson, Christopher A. Vick.
* Extended version.
*/
* by Keith D. Cooper, L. Taylor Simpson, Christopher A. Vick.
* Extended version.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config.h"
-#endif
#include "adt/pdeq.h"
#include "iroptimize.h"
#include "adt/pdeq.h"
#include "iroptimize.h"
@@
-52,7
+50,7
@@
#include "irloop_t.h"
#include "array.h"
#include "firmstat.h"
#include "irloop_t.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
+303,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
+320,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
+358,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
+389,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
+408,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
+419,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
+467,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
+493,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
+662,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;
@@
-935,7
+937,7
@@
static void dfs(ir_node *irn, iv_env *env)
for (i = 0; i < n; ++i) {
ir_node *pred = get_irn_n(irn, i);
for (i = 0; i < n; ++i) {
ir_node *pred = get_irn_n(irn, i);
- if (
irn_not
_visited(pred))
+ if (
!irn
_visited(pred))
dfs(pred, env);
}
}
dfs(pred, env);
}
}
@@
-947,7
+949,7
@@
static void dfs(ir_node *irn, iv_env *env)
push(env, irn);
/* handle the block */
push(env, irn);
/* handle the block */
- if (
irn_not
_visited(block))
+ if (
!irn
_visited(block))
dfs(block, env);
n = get_irn_arity(irn);
dfs(block, env);
n = get_irn_arity(irn);
@@
-955,7
+957,7
@@
static void dfs(ir_node *irn, iv_env *env)
ir_node *pred = get_irn_n(irn, i);
node_entry *o = get_irn_ne(pred, env);
ir_node *pred = get_irn_n(irn, i);
node_entry *o = get_irn_ne(pred, env);
- if (
irn_not
_visited(pred)) {
+ if (
!irn
_visited(pred)) {
dfs(pred, env);
node->low = MIN(node->low, o->low);
}
dfs(pred, env);
node->low = MIN(node->low, o->low);
}
@@
-993,7
+995,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);
@@
-1006,11
+1008,11
@@
static void do_dfs(ir_graph *irg, iv_env *env) {
for (i = 0; i < n; ++i) {
ir_node *ka = get_End_keepalive(end, i);
for (i = 0; i < n; ++i) {
ir_node *ka = get_End_keepalive(end, i);
- if (
irn_not
_visited(ka))
+ if (
!irn
_visited(ka))
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
+1110,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
+1123,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
+1187,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
+1261,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
+1295,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));