Hi!

Related to the PR69207 changes, the problem there has been that
fold_convertible_p allowed conversion from a vector type to same sized
integral type, and fold_convert used NOP_EXPR in that case.  But,
such an operation is much better handled using VCE.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-01-11  Jakub Jelinek  <ja...@redhat.com>

        * fold-const.c (fold_convertible_p): Don't return true
        for conversion of VECTOR_TYPE to same sized integral type.
        (fold_convert_loc): Fix up formatting.  Fold conversion of
        VECTOR_TYPE to same sized integral type using VIEW_CONVERT_EXPR
        instead of NOP_EXPR.

--- gcc/fold-const.c.jj 2016-01-09 08:36:15.000000000 +0100
+++ gcc/fold-const.c    2016-01-11 11:53:41.470765831 +0100
@@ -2182,11 +2182,8 @@ fold_convertible_p (const_tree type, con
     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
     case POINTER_TYPE: case REFERENCE_TYPE:
     case OFFSET_TYPE:
-      if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig)
-         || TREE_CODE (orig) == OFFSET_TYPE)
-        return true;
-      return (TREE_CODE (orig) == VECTOR_TYPE
-             && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig)));
+      return (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig)
+             || TREE_CODE (orig) == OFFSET_TYPE);
 
     case REAL_TYPE:
     case FIXED_POINT_TYPE:
@@ -2241,11 +2238,11 @@ fold_convert_loc (location_t loc, tree t
        return fold_build1_loc (loc, NOP_EXPR, type, arg);
       if (TREE_CODE (orig) == COMPLEX_TYPE)
        return fold_convert_loc (loc, type,
-                            fold_build1_loc (loc, REALPART_EXPR,
-                                         TREE_TYPE (orig), arg));
+                                fold_build1_loc (loc, REALPART_EXPR,
+                                                 TREE_TYPE (orig), arg));
       gcc_assert (TREE_CODE (orig) == VECTOR_TYPE
                  && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig)));
-      return fold_build1_loc (loc, NOP_EXPR, type, arg);
+      return fold_build1_loc (loc, VIEW_CONVERT_EXPR, type, arg);
 
     case REAL_TYPE:
       if (TREE_CODE (arg) == INTEGER_CST)

        Jakub

Reply via email to