Blame SOURCES/gcc48-pr72747.patch

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