Blame SOURCES/gcc48-rh1546728.patch

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