From: Richard Sandiford Date: Mon, 2 Dec 2019 17:51:08 +0000 (+0000) Subject: Tighten check for vector types in fold_convertible_p (PR 92741) X-Git-Tag: misc/cutover-git~795 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fddcfa5b84bf8a063e3e1347d787df5a36beceb2;p=thirdparty%2Fgcc.git Tighten check for vector types in fold_convertible_p (PR 92741) In this PR, IPA-CP was misled into using NOP_EXPR rather than VIEW_CONVERT_EXPR to reinterpret a vector of 4 shorts as a vector of 2 ints. This tripped the tree-cfg.c assert I'd added in r278245. 2019-12-02 Richard Sandiford gcc/ PR middle-end/92741 * fold-const.c (fold_convertible_p): Check vector types more thoroughly. gcc/testsuite/ PR middle-end/92741 * gcc.dg/pr92741.c: New test. From-SVN: r278910 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b7d3cc632bcb..824e63566074 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-12-02 Richard Sandiford + + PR middle-end/92741 + * fold-const.c (fold_convertible_p): Check vector types more + thoroughly. + 2019-12-02 Richard Sandiford * config/aarch64/aarch64.c (aarch64_report_sve_required): New function. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 02daacdb36b8..d7a77a9848a7 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2375,10 +2375,15 @@ fold_convertible_p (const_tree type, const_tree arg) case REAL_TYPE: case FIXED_POINT_TYPE: - case VECTOR_TYPE: case VOID_TYPE: return TREE_CODE (type) == TREE_CODE (orig); + case VECTOR_TYPE: + return (VECTOR_TYPE_P (orig) + && known_eq (TYPE_VECTOR_SUBPARTS (type), + TYPE_VECTOR_SUBPARTS (orig)) + && fold_convertible_p (TREE_TYPE (type), TREE_TYPE (orig))); + default: return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f4a5bb24e1a7..8dd2633d6437 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-02 Richard Sandiford + + PR middle-end/92741 + * gcc.dg/pr92741.c: New test. + 2019-12-02 Richard Sandiford * gcc.target/aarch64/sve/acle/general/nosve_4.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr92741.c b/gcc/testsuite/gcc.dg/pr92741.c new file mode 100644 index 000000000000..8524c86557b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr92741.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions -fno-inline" } */ + +typedef int vh __attribute__ ((__vector_size__ (2 * sizeof (int)))); +typedef short int cq __attribute__ ((__vector_size__ (4 * sizeof (short int)))); + +static void +id (int *r8, vh *tu) +{ + *(vh *) r8 = *tu; +} + +void +mr (void) +{ + int r8; + cq he = { 0, }; + + id (&r8, (vh *) &he); +}