Blame SOURCES/gcc48-rh1546728.patch

8178f7
2015-09-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
8178f7
8178f7
	* optabs.c (expand_binop): Don't create a broadcast vector with a
8178f7
	source element wider than the inner mode.
8178f7
8178f7
	* gcc.target/powerpc/vec-shift.c: New test.
8178f7
8178f7
--- gcc/optabs.c
8178f7
+++ gcc/optabs.c
8178f7
@@ -1608,6 +1608,15 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
8178f7
 
8178f7
       if (otheroptab && optab_handler (otheroptab, mode) != CODE_FOR_nothing)
8178f7
 	{
8178f7
+	  /* The scalar may have been extended to be too wide.  Truncate
8178f7
+	     it back to the proper size to fit in the broadcast vector.  */
8178f7
+	  machine_mode inner_mode = GET_MODE_INNER (mode);
8178f7
+	  if (!CONST_INT_P (op1)
8178f7
+	      && (GET_MODE_BITSIZE (inner_mode)
8178f7
+		  < GET_MODE_BITSIZE (GET_MODE (op1))))
8178f7
+	    op1 = force_reg (inner_mode,
8178f7
+			     simplify_gen_unary (TRUNCATE, inner_mode, op1,
8178f7
+						 GET_MODE (op1)));
8178f7
 	  rtx vop1 = expand_vector_broadcast (mode, op1);
8178f7
 	  if (vop1)
8178f7
 	    {
8178f7
--- /dev/null
8178f7
+++ gcc/testsuite/gcc.target/powerpc/vec-shift.c
8178f7
@@ -0,0 +1,20 @@
8178f7
+/* { dg-do compile { target { powerpc*-*-* } } } */
8178f7
+/* { dg-require-effective-target powerpc_altivec_ok } */
8178f7
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
8178f7
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
8178f7
+/* { dg-options "-mcpu=power7 -O2" } */
8178f7
+
8178f7
+/* This used to ICE.  During gimplification, "i" is widened to an unsigned
8178f7
+   int.  We used to fail at expand time as we tried to cram an SImode item
8178f7
+   into a QImode memory slot.  This has been fixed to properly truncate the
8178f7
+   shift amount when splatting it into a vector.  */
8178f7
+
8178f7
+typedef unsigned char v16ui __attribute__((vector_size(16)));
8178f7
+
8178f7
+v16ui vslb(v16ui v, unsigned char i)
8178f7
+{
8178f7
+	return v << i;
8178f7
+}
8178f7
+
8178f7
+/* { dg-final { scan-assembler "vspltb" } } */
8178f7
+/* { dg-final { scan-assembler "vslb" } } */