From 438d9c4afa635c7a1475feebbc220fe8d335c664 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 29 Nov 2019 09:18:48 +0000 Subject: [PATCH] =?utf8?q?re=20PR=20tree-optimization/92715=20(error:=20po?= =?utf8?q?sition=20plus=20size=20exceeds=20size=20of=20referenced=20object?= =?utf8?q?=20in=20=20=E2=80=98bit=5Ffield=5Fref=E2=80=99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2019-11-29 Richard Biener PR tree-optimization/92715 * tree-ssa-forwprop.c (simplify_vector_constructor): Bail out for uniform vectors and source vectors with less elements than the destination. * gcc.dg/torture/pr92715.c: New testcase. From-SVN: r278833 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr92715.c | 17 +++++++++++++++++ gcc/tree-ssa-forwprop.c | 11 +++++++---- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr92715.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 229e2b6b7ef..3eaa9acf743 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-11-29 Richard Biener + + PR tree-optimization/92715 + * tree-ssa-forwprop.c (simplify_vector_constructor): Bail + out for uniform vectors and source vectors with less elements + than the destination. + 2019-11-29 Martin Liska PR lto/91574 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 45c9de34b61..5d323652dba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-29 Richard Biener + + PR tree-optimization/92715 + * gcc.dg/torture/pr92715.c: New testcase. + 2019-11-29 Jakub Jelinek PR c++/60228 diff --git a/gcc/testsuite/gcc.dg/torture/pr92715.c b/gcc/testsuite/gcc.dg/torture/pr92715.c new file mode 100644 index 00000000000..170179c2032 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr92715.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ + +typedef double v4si __attribute__((vector_size(32))); +typedef double v2si __attribute__((vector_size(16))); + +void foo (v4si *dstp, v2si *srcp) +{ + v2si src = *srcp; + *dstp = (v4si) { src[0], src[1], src[0], src[1] }; +} + +void bar (v4si *dstp, v2si *srcp) +{ + v2si src = *srcp; + *dstp = (v4si) { src[0], src[0], src[0], src[0] }; +} diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index b275a637347..36e6267cf55 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -2038,13 +2038,13 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) constructor_elt *elt; bool maybe_ident; - gcc_checking_assert (gimple_assign_rhs_code (stmt) == CONSTRUCTOR); - op = gimple_assign_rhs1 (stmt); type = TREE_TYPE (op); - gcc_checking_assert (TREE_CODE (type) == VECTOR_TYPE); + gcc_checking_assert (TREE_CODE (op) == CONSTRUCTOR + && TREE_CODE (type) == VECTOR_TYPE); - if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts)) + if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts) + || uniform_vector_p (op)) return false; elem_type = TREE_TYPE (type); elem_size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type)); @@ -2136,6 +2136,9 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) || ! VECTOR_TYPE_P (TREE_TYPE (orig[0]))) return false; refnelts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (orig[0])).to_constant (); + /* We currently do not handle larger destination vectors. */ + if (refnelts < nelts) + return false; if (maybe_ident) { -- 2.30.2