rs6000.c (rs6000_expand_vector_set): Adjust for little endian.
authorBill Schmidt <wschmidt@vnet.linux.ibm.com>
Sun, 3 Nov 2013 00:06:43 +0000 (00:06 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Sun, 3 Nov 2013 00:06:43 +0000 (00:06 +0000)
gcc:

2013-11-02  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>

* config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for
little endian.

gcc/testsuite:

2013-11-02  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>

* gcc.dg/vmx/vec-set.c: New.

From-SVN: r204321

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vmx/vec-set.c [new file with mode: 0644]

index 2399a61..cf54baf 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-02  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>
+
+       * config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for
+       little endian.
+
 2013-11-02  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/constraints.md (Ts, Tv): New address constrains.
index 1006eec..31871b4 100644 (file)
@@ -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));
 }
 
index 1abd7c1..e0dad49 100644 (file)
@@ -1,3 +1,7 @@
+2013-11-02  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>
+
+       * gcc.dg/vmx/vec-set.c: New.
+
 2013-11-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        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 (file)
index 0000000..fa11c47
--- /dev/null
@@ -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");
+}