Blame SOURCES/gcc48-pr72717.patch

802f23
2016-12-13  Michael Meissner  <meissner@linux.vnet.ibm.com>
802f23
802f23
	Backport from mainline
802f23
	2016-12-07  Michael Meissner  <meissner@linux.vnet.ibm.com>
802f23
802f23
	PR target/72717
802f23
	* config/rs6000/rs6000.c (rs6000_expand_vector_init): If the
802f23
	V2DImode elements are SUBREG's convert the result into DImode
802f23
	rather than failing in emit_move_insn.
802f23
802f23
--- gcc/testsuite/gcc.target/powerpc/pr72717.c	(nonexistent)
802f23
+++ gcc/testsuite/gcc.target/powerpc/pr72717.c	(revision 243626)
802f23
@@ -0,0 +1,18 @@
802f23
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
802f23
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
802f23
+/* { dg-require-effective-target powerpc_p8vector_ok } */
802f23
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
802f23
+/* { dg-options "-mcpu=power8 -O2" } */
802f23
+
802f23
+typedef long V __attribute__((__vector_size__(32)));
802f23
+
802f23
+extern void foo (V *, V*);
802f23
+
802f23
+/* This test generated an failure in emit_move_insn.  */
802f23
+
802f23
+void
802f23
+foo(V *p, V *q)
802f23
+{
802f23
+  V v = *q;
802f23
+  *p = v << v[0];
802f23
+}
802f23
--- gcc/config/rs6000/rs6000.c	(revision 243625)
802f23
+++ gcc/config/rs6000/rs6000.c	(revision 243626)
802f23
@@ -6667,25 +6667,43 @@
802f23
   /* Double word values on VSX can use xxpermdi or lxvdsx.  */
802f23
   if (VECTOR_MEM_VSX_P (mode) && (mode == V2DFmode || mode == V2DImode))
802f23
     {
802f23
-      rtx op0 = XVECEXP (vals, 0, 0);
802f23
-      rtx op1 = XVECEXP (vals, 0, 1);
802f23
+      rtx op[2];
802f23
+      size_t i;
802f23
+      size_t num_elements = (all_same) ? 1 : 2;
802f23
+      for (i = 0; i < num_elements; i++)
802f23
+	{
802f23
+	  op[i] = XVECEXP (vals, 0, i);
802f23
+	  /* Just in case there is a SUBREG with a smaller mode, do a
802f23
+	     conversion.  */
802f23
+	  if (GET_MODE (op[i]) != inner_mode)
802f23
+	    {
802f23
+	      rtx tmp = gen_reg_rtx (inner_mode);
802f23
+	      convert_move (tmp, op[i], 0);
802f23
+	      op[i] = tmp;
802f23
+	    }
802f23
+	  /* Allow load with splat double word.  */
802f23
+	  else if (MEM_P (op[i]))
802f23
+	    {
802f23
+	      if (!all_same)
802f23
+		op[i] = force_reg (inner_mode, op[i]);
802f23
+	    }
802f23
+	  else if (!REG_P (op[i]))
802f23
+	    op[i] = force_reg (inner_mode, op[i]);
802f23
+	}
802f23
+
802f23
       if (all_same)
802f23
 	{
802f23
-	  if (!MEM_P (op0) && !REG_P (op0))
802f23
-	    op0 = force_reg (inner_mode, op0);
802f23
 	  if (mode == V2DFmode)
802f23
-	    emit_insn (gen_vsx_splat_v2df (target, op0));
802f23
+	    emit_insn (gen_vsx_splat_v2df (target, op[0]));
802f23
 	  else
802f23
-	    emit_insn (gen_vsx_splat_v2di (target, op0));
802f23
+	    emit_insn (gen_vsx_splat_v2di (target, op[0]));
802f23
 	}
802f23
       else
802f23
 	{
802f23
-	  op0 = force_reg (inner_mode, op0);
802f23
-	  op1 = force_reg (inner_mode, op1);
802f23
 	  if (mode == V2DFmode)
802f23
-	    emit_insn (gen_vsx_concat_v2df (target, op0, op1));
802f23
+	    emit_insn (gen_vsx_concat_v2df (target, op[0], op[1]));
802f23
 	  else
802f23
-	    emit_insn (gen_vsx_concat_v2di (target, op0, op1));
802f23
+	    emit_insn (gen_vsx_concat_v2di (target, op[0], op[1]));
802f23
 	}
802f23
       return;
802f23
     }