Blame SOURCES/gcc48-pr72747.patch

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