Blame SOURCES/gcc48-pr72747.patch

56d343
2016-11-02  Will Schmidt <will_schmidt@vnet.ibm.com>
56d343
56d343
	Backport from trunk
56d343
	2016-10-26  Will Schmidt <will_schmidt@vnet.ibm.com>
56d343
56d343
	PR middle-end/72747
56d343
	* gimplify.c (gimplify_init_constructor): Move emit of constructor
56d343
	assignment to earlier in the if/else logic.
56d343
56d343
	* c-c++-common/pr72747-1.c: New test.
56d343
	* c-c++-common/pr72747-2.c: Likewise.
56d343
56d343
--- gcc/gimplify.c	(revision 241792)
56d343
+++ gcc/gimplify.c	(revision 241793)
56d343
@@ -4273,24 +4273,23 @@ gimplify_init_constructor (tree *expr_p,
56d343
 
56d343
   if (ret == GS_ERROR)
56d343
     return GS_ERROR;
56d343
-  else if (want_value)
56d343
+  /* If we have gimplified both sides of the initializer but have
56d343
+     not emitted an assignment, do so now.  */
56d343
+  if (*expr_p)
56d343
+    {
56d343
+      tree lhs = TREE_OPERAND (*expr_p, 0);
56d343
+      tree rhs = TREE_OPERAND (*expr_p, 1);
56d343
+      gimple init = gimple_build_assign (lhs, rhs);
56d343
+      gimplify_seq_add_stmt (pre_p, init);
56d343
+    }
56d343
+  if (want_value)
56d343
     {
56d343
       *expr_p = object;
56d343
       return GS_OK;
56d343
     }
56d343
   else
56d343
     {
56d343
-      /* If we have gimplified both sides of the initializer but have
56d343
-	 not emitted an assignment, do so now.  */
56d343
-      if (*expr_p)
56d343
-	{
56d343
-	  tree lhs = TREE_OPERAND (*expr_p, 0);
56d343
-	  tree rhs = TREE_OPERAND (*expr_p, 1);
56d343
-	  gimple init = gimple_build_assign (lhs, rhs);
56d343
-	  gimplify_seq_add_stmt (pre_p, init);
56d343
-	  *expr_p = NULL;
56d343
-	}
56d343
-
56d343
+      *expr_p = NULL;
56d343
       return GS_ALL_DONE;
56d343
     }
56d343
 }
56d343
--- gcc/testsuite/c-c++-common/pr72747-1.c	(nonexistent)
56d343
+++ gcc/testsuite/c-c++-common/pr72747-1.c	(revision 241793)
56d343
@@ -0,0 +1,16 @@
56d343
+/* { dg-do compile } */
56d343
+/* { dg-require-effective-target powerpc_altivec_ok } */
56d343
+/* { dg-options "-maltivec -fdump-tree-gimple" } */
56d343
+
56d343
+/* PR 72747: Test that cascaded definition is happening for constant vectors. */
56d343
+
56d343
+#include <altivec.h>
56d343
+
56d343
+int main (int argc, char *argv[])
56d343
+{
56d343
+	__vector int v1,v2;
56d343
+	v1 = v2 = vec_splats ((int) 42);
56d343
+	return 0;
56d343
+}
56d343
+/* { dg-final { scan-tree-dump-times " v2 = { 42, 42, 42, 42 }" 1 "gimple" } } */
56d343
+
56d343
--- gcc/testsuite/c-c++-common/pr72747-2.c	(nonexistent)
56d343
+++ gcc/testsuite/c-c++-common/pr72747-2.c	(revision 241793)
56d343
@@ -0,0 +1,18 @@
56d343
+/* { dg-do compile } */
56d343
+/* { dg-require-effective-target powerpc_altivec_ok } */
56d343
+/* { dg-options "-c -maltivec -fdump-tree-gimple" } */
56d343
+
56d343
+/* PR 72747: test that cascaded definition is happening for non constants. */
56d343
+
56d343
+void foo ()
56d343
+{
56d343
+  extern int i;
56d343
+  __vector int v,w;
56d343
+    v = w = (vector int) { i };
56d343
+}
56d343
+
56d343
+int main (int argc, char *argv[])
56d343
+{
56d343
+  return 0;
56d343
+}
56d343
+/* { dg-final { scan-tree-dump-times " w = " 1 "gimple" } } */