+ if (!is_downconv(mode, dest_mode)) {
+ return 1;
+ }
+
+ if (is_Conv(node)) {
+ ir_node *pred = get_Conv_op(node);
+ ir_mode *pred_mode = get_irn_mode(pred);
+
+ if (!values_in_mode(dest_mode, pred_mode)) {
+ return 1;
+ }
+ return get_conv_costs(get_Conv_op(node), dest_mode) - 1;
+ }
+
+ if (!is_optimizable_node(node, dest_mode)) {
+ return 1;
+ }
+
+ costs = 0;
+ // The shift count does not participate in the conv optimisation
+ arity = is_Shl(node) ? 1 : get_irn_arity(node);
+ for (i = 0; i < arity; ++i) {
+ ir_node *pred = get_irn_n(node, i);
+ costs += imin(get_conv_costs(pred, dest_mode), 1);
+ }
+
+ return costs;