DEBUG_ONLY(static firm_dbg_module_t *dbg);
static inline int imin(int a, int b) { return a < b ? a : b; }
DEBUG_ONLY(static firm_dbg_module_t *dbg);
static inline int imin(int a, int b) { return a < b ? a : b; }
#if 0 // TODO
/* Take the minimum of the conversion costs for Phi predecessors as only one
* branch is actually executed at a time */
#if 0 // TODO
/* Take the minimum of the conversion costs for Phi predecessors as only one
* branch is actually executed at a time */
- if (!mode_is_int(mode) || !is_optimizable_node(node)) {
+ if (!is_downconv(mode, dest_mode)) {
+ return 1;
+ }
+
+ if (is_Conv(node)) {
+ return get_conv_costs(get_Conv_op(node), dest_mode) - 1;
+ }
+
+ if (!is_optimizable_node(node)) {
static ir_node *place_conv(ir_node *node, ir_mode *dest_mode)
{
ir_node *block = get_nodes_block(node);
static ir_node *place_conv(ir_node *node, ir_mode *dest_mode)
{
ir_node *block = get_nodes_block(node);
- ir_node *conv = new_r_Conv(current_ir_graph, block, node, dest_mode);
+ ir_node *conv = new_r_Conv(block, node, dest_mode);
- if (is_Conv(node) && is_downconv(mode, dest_mode)) {
+ if (!is_downconv(mode, dest_mode)) {
+ return place_conv(node, dest_mode);
+ }
+
+ if (is_Conv(node)) {
/* TODO, backends (at least ia32) can't handle it at the moment,
and it's probably not more efficient on most archs */
#if 0
/* TODO, backends (at least ia32) can't handle it at the moment,
and it's probably not more efficient on most archs */
#if 0
/* - 1 for the initial conv */
costs = get_conv_costs(pred, mode) - 1;
DB((dbg, LEVEL_2, "Costs for %+F -> %+F: %d\n", node, pred, costs));
/* - 1 for the initial conv */
costs = get_conv_costs(pred, mode) - 1;
DB((dbg, LEVEL_2, "Costs for %+F -> %+F: %d\n", node, pred, costs));
transformed = conv_transform(pred, mode);
if (node != transformed) {
exchange(node, transformed);
transformed = conv_transform(pred, mode);
if (node != transformed) {
exchange(node, transformed);
FIRM_DBG_REGISTER(dbg, "firm.opt.conv");
DB((dbg, LEVEL_1, "===> Performing conversion optimization on %+F\n", irg));
edges_assure(irg);
do {
FIRM_DBG_REGISTER(dbg, "firm.opt.conv");
DB((dbg, LEVEL_1, "===> Performing conversion optimization on %+F\n", irg));
edges_assure(irg);
do {
irg_walk_graph(irg, NULL, conv_opt_walker, NULL);
local_optimize_graph(irg);
invalidate |= changed;
irg_walk_graph(irg, NULL, conv_opt_walker, NULL);
local_optimize_graph(irg);
invalidate |= changed;