Blame SOURCES/gcc48-pr72747.patch

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