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-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fddcfa5b84bf8a063e3e1347d787df5a36beceb2;p=gcc.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 b7d3cc632bc..824e6356607 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 02daacdb36b..d7a77a9848a 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 f4a5bb24e1a..8dd2633d643 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 00000000000..8524c86557b --- /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); +}