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