diff mbox

[PowerPC] altivec_expand_vec_perm_const selects wrong field for splat in LE mode

Message ID 1374599446.3633.113.camel@gnopaine
State New
Headers show

Commit Message

Bill Schmidt July 23, 2013, 5:10 p.m. UTC
This patch fixes another small little-endian problem with vectors on
PowerPC.  Element numbering is reversed when selecting a field for a
vector splat operation.  Fixing this removes a regression from the test
suite when run in LE mode (gcc.dg/vect/slp-perm-3.c).

Patch by Anton Blanchard.  Bootstrapped and tested on
powerpc64-unknown-linux-gnu with no new regressions.  Ok for trunk?

Thanks,
Bill


2013-07-23  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
	    Anton Blanchard <anton@au1.ibm.com>

	* config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Correct
	selection of field for vector splat in little endian mode.

Comments

David Edelsohn July 23, 2013, 5:55 p.m. UTC | #1
On Tue, Jul 23, 2013 at 1:10 PM, Bill Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> This patch fixes another small little-endian problem with vectors on
> PowerPC.  Element numbering is reversed when selecting a field for a
> vector splat operation.  Fixing this removes a regression from the test
> suite when run in LE mode (gcc.dg/vect/slp-perm-3.c).
>
> Patch by Anton Blanchard.  Bootstrapped and tested on
> powerpc64-unknown-linux-gnu with no new regressions.  Ok for trunk?
>
> Thanks,
> Bill
>
>
> 2013-07-23  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>             Anton Blanchard <anton@au1.ibm.com>
>
>         * config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Correct
>         selection of field for vector splat in little endian mode.

This patch is okay.

Thanks, David
diff mbox

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 201149)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -28460,9 +28460,10 @@  altivec_expand_vec_perm_const (rtx operands[4])
 	      break;
 	  if (i == 16)
 	    {
+	      int field = BYTES_BIG_ENDIAN ? elt / 2 : 7 - elt / 2;
 	      x = gen_reg_rtx (V8HImode);
 	      emit_insn (gen_altivec_vsplth (x, gen_lowpart (V8HImode, op0),
-					     GEN_INT (elt / 2)));
+					     GEN_INT (field)));
 	      emit_move_insn (target, gen_lowpart (V16QImode, x));
 	      return true;
 	    }
@@ -28478,9 +28479,10 @@  altivec_expand_vec_perm_const (rtx operands[4])
 	      break;
 	  if (i == 16)
 	    {
+	      int field = BYTES_BIG_ENDIAN ? elt / 4 : 3 - elt / 4;
 	      x = gen_reg_rtx (V4SImode);
 	      emit_insn (gen_altivec_vspltw (x, gen_lowpart (V4SImode, op0),
-					     GEN_INT (elt / 4)));
+					     GEN_INT (field)));
 	      emit_move_insn (target, gen_lowpart (V16QImode, x));
 	      return true;
 	    }