]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vector.md (vec_shr_<mode>): Fix to do a shift instead of a rotate.
authorPat Haugen <pthaugen@us.ibm.com>
Thu, 27 Aug 2015 18:42:04 +0000 (18:42 +0000)
committerPat Haugen <pthaugen@gcc.gnu.org>
Thu, 27 Aug 2015 18:42:04 +0000 (18:42 +0000)
* config/rs6000/vector.md (vec_shr_<mode>): Fix to do a shift
instead of a rotate.

* gcc.target/powerpc/vec-shr.c: New.

From-SVN: r227273

gcc/ChangeLog
gcc/config/rs6000/vector.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/vec-shr.c [new file with mode: 0644]

index 8f7d216911526cfb47a24cbd7135b1c931156529..04577f836856228af4a271f7c80a79246fdd04fb 100644 (file)
@@ -1,3 +1,11 @@
+2015-08-27  Pat Haugen  <pthaugen@us.ibm.com>
+
+       Backport from mainline:
+       2015-08-27  Pat Haugen  <pthaugen@us.ibm.com>
+
+       * config/rs6000/vector.md (vec_shr_<mode>): Fix to do a shift
+       instead of a rotate.
+
 2015-08-24  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        Back port from mainline:
index edbb83161d142b1a562735635fe90ef65b09fbbf..d81cccdf7289832dcf10858cfeded89baae2f969 100644 (file)
   rtx bitshift = operands[2];
   rtx shift;
   rtx insn;
+  rtx zero_reg;
   HOST_WIDE_INT bitshift_val;
   HOST_WIDE_INT byteshift_val;
 
   if (bitshift_val & 0x7)
     FAIL;
   byteshift_val = bitshift_val >> 3;
+  zero_reg = gen_reg_rtx (<MODE>mode);
+  emit_move_insn (zero_reg, CONST0_RTX (<MODE>mode));
   if (TARGET_VSX && (byteshift_val & 0x3) == 0)
     {
       shift = gen_rtx_CONST_INT (QImode, byteshift_val >> 2);
-      insn = gen_vsx_xxsldwi_<mode> (operands[0], operands[1], operands[1],
+      insn = gen_vsx_xxsldwi_<mode> (operands[0], operands[1], zero_reg,
                                     shift);
     }
   else
     {
       shift = gen_rtx_CONST_INT (QImode, byteshift_val);
-      insn = gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
+      insn = gen_altivec_vsldoi_<mode> (operands[0], operands[1], zero_reg,
                                        shift);
     }
 
   rtx bitshift = operands[2];
   rtx shift;
   rtx insn;
+  rtx zero_reg;
   HOST_WIDE_INT bitshift_val;
   HOST_WIDE_INT byteshift_val;
 
   if (bitshift_val & 0x7)
     FAIL;
   byteshift_val = 16 - (bitshift_val >> 3);
+  zero_reg = gen_reg_rtx (<MODE>mode);
+  emit_move_insn (zero_reg, CONST0_RTX (<MODE>mode));
   if (TARGET_VSX && (byteshift_val & 0x3) == 0)
     {
       shift = gen_rtx_CONST_INT (QImode, byteshift_val >> 2);
-      insn = gen_vsx_xxsldwi_<mode> (operands[0], operands[1], operands[1],
+      insn = gen_vsx_xxsldwi_<mode> (operands[0], zero_reg, operands[1],
                                     shift);
     }
   else
     {
       shift = gen_rtx_CONST_INT (QImode, byteshift_val);
-      insn = gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
+      insn = gen_altivec_vsldoi_<mode> (operands[0], zero_reg, operands[1],
                                        shift);
     }
 
index 3029c6f127cdfc594476dcdd0e7249ba55868abb..b5a53a305b94885f96df316769c68f6688a16733 100644 (file)
@@ -1,3 +1,10 @@
+2015-08-27  Pat Haugen  <pthaugen@us.ibm.com>
+
+       Backport from mainline:
+       2015-08-27  Pat Haugen  <pthaugen@us.ibm.com>
+
+       * gcc.target/powerpc/vec-shr.c: New.
+
 2015-08-24  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-shr.c b/gcc/testsuite/gcc.target/powerpc/vec-shr.c
new file mode 100644 (file)
index 0000000..31a27c8
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-inline" } */
+
+#include <stdlib.h>
+
+typedef struct { double r, i; } complex;
+#define LEN 30
+complex c[LEN];
+double d[LEN];
+
+void
+foo (complex *c, double *d, int len1)
+{
+  int i;
+  for (i = 0; i < len1; i++)
+    {
+      c[i].r = d[i];
+      c[i].i = 0.0;
+    }
+}
+
+int
+main (void)
+{
+  int i;
+  for (i = 0; i < LEN; i++)
+    d[i] = (double) i;
+  foo (c, d, LEN);
+  for (i=0;i<LEN;i++)
+    if ((c[i].r != (double) i) || (c[i].i != 0.0))
+      abort ();
+  return 0;
+}
+