From 93895581f9c8c8591cdbd7152756a63d330736b9 Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Sun, 3 Nov 2013 00:06:43 +0000 Subject: [PATCH] rs6000.c (rs6000_expand_vector_set): Adjust for little endian. gcc: 2013-11-02 Bill Schmidt * config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for little endian. gcc/testsuite: 2013-11-02 Bill Schmidt * gcc.dg/vmx/vec-set.c: New. From-SVN: r204321 --- gcc/ChangeLog | 5 +++++ gcc/config/rs6000/rs6000.c | 25 +++++++++++++++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/vmx/vec-set.c | 14 ++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vmx/vec-set.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2399a61..cf54baf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-11-02 Bill Schmidt + + * config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for + little endian. + 2013-11-02 Uros Bizjak * config/i386/constraints.md (Ts, Tv): New address constrains. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 1006eec..31871b4 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5529,10 +5529,27 @@ rs6000_expand_vector_set (rtx target, rtx val, int elt) XVECEXP (mask, 0, elt*width + i) = GEN_INT (i + 0x10); x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0)); - x = gen_rtx_UNSPEC (mode, - gen_rtvec (3, target, reg, - force_reg (V16QImode, x)), - UNSPEC_VPERM); + + if (BYTES_BIG_ENDIAN) + x = gen_rtx_UNSPEC (mode, + gen_rtvec (3, target, reg, + force_reg (V16QImode, x)), + UNSPEC_VPERM); + else + { + /* Invert selector. */ + rtx splat = gen_rtx_VEC_DUPLICATE (V16QImode, + gen_rtx_CONST_INT (QImode, -1)); + rtx tmp = gen_reg_rtx (V16QImode); + emit_move_insn (tmp, splat); + x = gen_rtx_MINUS (V16QImode, tmp, force_reg (V16QImode, x)); + emit_move_insn (tmp, x); + + /* Permute with operands reversed and adjusted selector. */ + x = gen_rtx_UNSPEC (mode, gen_rtvec (3, reg, target, tmp), + UNSPEC_VPERM); + } + emit_insn (gen_rtx_SET (VOIDmode, target, x)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1abd7c1..e0dad49 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-11-02 Bill Schmidt + + * gcc.dg/vmx/vec-set.c: New. + 2013-11-02 Paolo Carlini PR c++/29234 diff --git a/gcc/testsuite/gcc.dg/vmx/vec-set.c b/gcc/testsuite/gcc.dg/vmx/vec-set.c new file mode 100644 index 0000000..fa11c47 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vmx/vec-set.c @@ -0,0 +1,14 @@ +#include "harness.h" + +vector short +vec_set (short m) +{ + return (vector short){m, 0, 0, 0, 0, 0, 0, 0}; +} + +static void test() +{ + check (vec_all_eq (vec_set (7), + ((vector short){7, 0, 0, 0, 0, 0, 0, 0})), + "vec_set"); +} -- 2.7.4