Blame SOURCES/gcc48-pr72717.patch

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