From: Janis Johnson Date: Sat, 8 Oct 2005 22:21:11 +0000 (+0000) Subject: Partial backport from mainline 2004-05-04 Paolo Bonzini Richard... X-Git-Tag: releases/gcc-3.4.5~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47606b31256f7062692e835b86bee20d7f6912af;p=thirdparty%2Fgcc.git Partial backport from mainline 2004-05-04 Paolo Bonzini Richard Henderson Partial backport from mainline 2004-05-04 Paolo Bonzini Richard Henderson * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ecebacdd2e17..70cff3d025ef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-10-08 Janis Johnson + + Partial backport from mainline + 2004-05-04 Paolo Bonzini + Richard Henderson + * 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 PR target/23644 diff --git a/gcc/c-common.c b/gcc/c-common.c index d79f2000250f..30f869a9a0d1 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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. */ diff --git a/gcc/c-common.h b/gcc/c-common.h index 7849730f161f..0576a0a3bd81 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -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); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 3da121e10f9e..42c7b77609bf 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6ee73905921d..77ec495dfe27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-10-08 Janis Johnson + + * gcc.dg/altivec-pr18583.c: New test. + 2005-09-21 Volker Reichelt 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 index 000000000000..48bfda366a72 --- /dev/null +++ b/gcc/testsuite/gcc.dg/altivec-pr18583.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } { "-maltivec" } { "" } } */ +/* { dg-options "-maltivec" } */ + +#include + +static const vector signed short c[1] = + {(const vector signed short){4095, 5681, 5351, 4816, 4095, 4816, 5351, 5681}};