Blame SOURCES/gcc48-pr72747.patch

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