- Changed keep logic: all nodes can be keeped yet, thi is necessary to fix fehler152
[libfirm] / ir / ir / iropt.c
index 37b5b87..219c7d7 100644 (file)
@@ -1219,16 +1219,15 @@ restart:
                                        goto restart;
                                }
                                /* else both are strict conv, second is superfluous */
-                       } else if (is_Proj(a)) {
-                               ir_node *pred = get_Proj_pred(a);
-                               if (is_Load(pred)) {
-                                       /* loads always return with the exact precision of n_mode */
-                                       assert(get_Load_mode(pred) == n_mode);
-                                       return a;
-                               }
-                               /* leave strict floating point Conv's */
-                               return n;
                        } else {
+                               if (is_Proj(a)) {
+                                       ir_node *pred = get_Proj_pred(a);
+                                       if (is_Load(pred)) {
+                                               /* loads always return with the exact precision of n_mode */
+                                               assert(get_Load_mode(pred) == n_mode);
+                                               return a;
+                                       }
+                               }
                                /* leave strict floating point Conv's */
                                return n;
                        }
@@ -1260,18 +1259,13 @@ restart:
                                        }
                                }
                        }
-                       if (mode_is_int(n_mode) && mode_is_float(a_mode)) {
+                       if (get_mode_arithmetic(n_mode) == irma_twos_complement &&
+                           get_mode_arithmetic(a_mode) == irma_ieee754) {
                                /* ConvI(ConvF(I)) -> I, iff float mantissa >= int mode */
-                               size_t int_mantissa = get_mode_size_bits(n_mode) - (mode_is_signed(n_mode) ? 1 : 0);
-                               size_t float_mantissa;
-                               /* FIXME There is no way to get the mantissa size of a mode */
-                               switch (get_mode_size_bits(a_mode)) {
-                                       case 32: float_mantissa = 23 + 1; break; // + 1 for implicit 1
-                                       case 64: float_mantissa = 52 + 1; break;
-                                       case 80: float_mantissa = 64 + 1; break;
-                                       default: float_mantissa = 0;      break;
-                               }
-                               if (float_mantissa != 0 && float_mantissa >= int_mantissa) {
+                               unsigned int_mantissa   = get_mode_size_bits(n_mode) - (mode_is_signed(n_mode) ? 1 : 0);
+                               unsigned float_mantissa = tarval_ieee754_get_mantissa_size(a_mode);
+
+                               if (float_mantissa >= int_mantissa) {
                                        n = b;
                                        DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_CONV);
                                        return n;
@@ -5322,9 +5316,7 @@ static ir_node *transform_node_End(ir_node *n) {
                } else if (is_irn_pinned_in_irg(ka) && is_Block_dead(get_nodes_block(ka))) {
                        continue;
                }
-               /* FIXME: beabi need to keep a Proj(M) */
-               if (is_Phi(ka) || is_irn_keep(ka) || is_Proj(ka))
-                       in[j++] = ka;
+               in[j++] = ka;
        }
        if (j != n_keepalives)
                set_End_keepalives(n, j, in);