beloopana: Remove duplicate comments.
[libfirm] / ir / opt / convopt.c
index fac7e32..a57db1b 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * 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.
  */
 
 /**
@@ -61,15 +47,18 @@ static inline int imin(int a, int b) { return a < b ? a : b; }
 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);
@@ -90,12 +79,11 @@ static ir_tarval* conv_const_tv(const ir_node* cnst, ir_mode* 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)
@@ -127,24 +115,7 @@ 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;