Blame SOURCES/gcc48-pr72747.patch

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