diff mbox series

Fix PR92715

Message ID nycvar.YFH.7.76.1911291016570.5566@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR92715 | expand

Commit Message

Richard Biener Nov. 29, 2019, 9:17 a.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-11-29  Richard Biener  <rguenther@suse.de>

	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.
diff mbox series

Patch

Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c	(revision 278827)
+++ gcc/tree-ssa-forwprop.c	(working copy)
@@ -2038,13 +2038,13 @@ 
   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 @@ 
       || ! 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)
     {
Index: gcc/testsuite/gcc.dg/torture/pr92715.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr92715.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr92715.c	(working copy)
@@ -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] };
+}