/*
- * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
- *
* This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
static bool is_optimizable_node(const ir_node *node, ir_mode *dest_mode)
{
switch (get_irn_opcode(node)) {
- case iro_Add:
+ case iro_Minus:
+ case iro_Phi:
case iro_And:
case iro_Eor:
- case iro_Minus:
- case iro_Mul:
- case iro_Not:
case iro_Or:
- case iro_Phi:
+ case iro_Not:
+ return true;
+ case iro_Add:
+ case iro_Mul:
case iro_Sub:
+ if (mode_is_float(get_irn_mode(node)))
+ return false;
return true;
case iro_Shl: {
int modulo_shift = get_mode_modulo_shift(dest_mode);
return tarval_convert_to(get_Const_tarval(cnst), dest_mode);
}
-static int is_downconv(ir_mode *src_mode, ir_mode *dest_mode)
+static bool is_downconv(ir_mode *src_mode, ir_mode *dest_mode)
{
- return
- mode_is_int(src_mode) &&
- mode_is_int(dest_mode) &&
- get_mode_size_bits(dest_mode) <= get_mode_size_bits(src_mode);
+ return ((mode_is_int(src_mode) && mode_is_int(dest_mode))
+ || (mode_is_float(src_mode) && mode_is_float(dest_mode)))
+ && get_mode_size_bits(dest_mode) <= get_mode_size_bits(src_mode);
}
static int get_conv_costs(const ir_node *node, ir_mode *dest_mode)
return -1;
}
-#if 0 // TODO
- /* Take the minimum of the conversion costs for Phi predecessors as only one
- * branch is actually executed at a time */
- if (is_Phi(node)) {
- int i;
- int arity = get_Phi_n_preds(node);
- int costs;
-
- costs = get_conv_costs(get_Phi_pred(node, 0), dest_mode);
- for (i = 1; i < arity; ++i) {
- ir_node *pred = get_Phi_pred(node, i);
- int c = get_conv_costs(pred, dest_mode);
- if (c < costs) costs = c;
- }
-
- return costs;
- }
-#endif
+ /* TODO: Phi nodes */
if (!is_downconv(mode, dest_mode)) {
return 1;