]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Partial backport from mainline 2004-05-04 Paolo Bonzini <bonzini@gnu.org> Richard...
authorJanis Johnson <janis187@us.ibm.com>
Sat, 8 Oct 2005 22:21:11 +0000 (22:21 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Sat, 8 Oct 2005 22:21:11 +0000 (22:21 +0000)
        Partial backport from mainline
2004-05-04 Paolo Bonzini  <bonzini@gnu.org>
   Richard Henderson  <rth@redhat.com>
* c-common.c (vector_types_convertible_p): New function.
* c-common.h: Declare it.
* c-typeck.c (digest_init): Use it.
testsuite:
* gcc.dg/altivec-pr18583.c: New test.

From-SVN: r105124

gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/altivec-pr18583.c [new file with mode: 0644]

index ecebacdd2e170ccd1d92058e3a8d36bc1cf3f434..70cff3d025effe5363b5e350e39ae38d40b6073b 100644 (file)
@@ -1,3 +1,12 @@
+2005-10-08  Janis Johnson  <janis187@us.ibm.com>
+
+        Partial backport from mainline
+       2004-05-04 Paolo Bonzini  <bonzini@gnu.org>
+                  Richard Henderson  <rth@redhat.com>
+       * c-common.c (vector_types_convertible_p): New function.
+       * c-common.h: Declare it.
+       * c-typeck.c (digest_init): Use it.
+
 2005-10-07  James E Wilson  <wilson@specifix.com>
 
        PR target/23644
index d79f2000250facd622a4f28108b32a69e522fa45..30f869a9a0d1d5c4b875df14f1ff8f98664a3075 100644 (file)
@@ -1273,6 +1273,18 @@ constant_fits_type_p (tree c, tree type)
   return !TREE_OVERFLOW (c);
 }
 
+/* Nonzero if vector types T1 and T2 can be converted to each other
+   without an explicit cast.  */
+int
+vector_types_convertible_p (tree t1, tree t2)
+{
+  return targetm.vector_opaque_p (t1)
+        || targetm.vector_opaque_p (t2)
+         || (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))
+            && INTEGRAL_TYPE_P (TREE_TYPE (t1))
+               == INTEGRAL_TYPE_P (TREE_TYPE (t2)));
+}
+
 /* Convert EXPR to TYPE, warning about conversion problems with constants.
    Invoke this function on every expression that is converted implicitly,
    i.e. because of language rules and not because of an explicit cast.  */
index 7849730f161ff5eb3ea45062494533bf16ecc80b..0576a0a3bd81e219a07ccbb3e3b5eac3b4f39f5f 100644 (file)
@@ -1261,6 +1261,8 @@ extern tree finish_label_address_expr (tree);
    different implementations.  Used in c-common.c.  */
 extern tree lookup_label (tree);
 
+extern int vector_types_convertible_p (tree t1, tree t2);
+
 extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
 
 extern int c_safe_from_p (rtx, tree);
index 3da121e10f9eb8a612cf9a71cece839ddd960425..42c7b77609bfbddd1755230fc6ae88bc2c0dd2ed 100644 (file)
@@ -4098,7 +4098,8 @@ digest_init (tree type, tree init, int require_constant)
      vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
      below and handle as a constructor.  */
   if (code == VECTOR_TYPE
-      && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT)
+      && TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE
+      && vector_types_convertible_p (TREE_TYPE (inside_init), type)
       && TREE_CONSTANT (inside_init))
     {
       if (TREE_CODE (inside_init) == VECTOR_CST
index 6ee73905921d84adde0af127069f3f4dc1445565..77ec495dfe27bbcec2e228b9e16592504d052651 100644 (file)
@@ -1,3 +1,7 @@
+2005-10-08  Janis Johnson  <janis187@us.ibm.com>
+
+       * gcc.dg/altivec-pr18583.c: New test.
+
 2005-09-21  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23965
diff --git a/gcc/testsuite/gcc.dg/altivec-pr18583.c b/gcc/testsuite/gcc.dg/altivec-pr18583.c
new file mode 100644 (file)
index 0000000..48bfda3
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-xfail-if "" { "powerpc-ibm-aix*" } { "-maltivec" } { "" } } */
+/* { dg-options "-maltivec" } */
+
+#include <altivec.h>
+
+static const vector signed short c[1] = 
+  {(const vector signed short){4095, 5681, 5351, 4816, 4095, 4816, 5351, 5681}};