This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, rs6000][trunk,4.7,4.6,4.5] Fix PR52457, wrong code for -O1 -m32 -mcpu=power7
- From: Peter Bergner <bergner at vnet dot ibm dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: David Edelsohn <dje dot gcc at gmail dot com>, Michael Meissner <meissner at linux dot ibm dot com>
- Date: Fri, 02 Mar 2012 09:57:36 -0600
- Subject: [PATCH, rs6000][trunk,4.7,4.6,4.5] Fix PR52457, wrong code for -O1 -m32 -mcpu=power7
The patch below fixes a typo in the vsx_set_<mode> pattern that causes
wrong code to be generated when using -mcpu=power7. This passed bootstrap
and regression testing on trunk using powerpc64-linux. Ok for trunk?
This is also broken on the 4.7, 4.6 and 4.5 branches, is this ok for
those release branches once the branches are open for fixes and my
bootstrapping/regtesting are complete?
Peter
* gcc/config/rs6000/vsx.md (vsx_set_<mode>): Reorder operands.
* gcc/testsuite/gcc.target/powerpc/pr52457.c: New test.
Index: gcc/config/rs6000/vsx.md
===================================================================
--- gcc/config/rs6000/vsx.md (revision 184791)
+++ gcc/config/rs6000/vsx.md (working copy)
@@ -1119,9 +1119,9 @@ (define_insn "vsx_set_<mode>"
"VECTOR_MEM_VSX_P (<MODE>mode)"
{
if (INTVAL (operands[3]) == 0)
- return \"xxpermdi %x0,%x1,%x2,1\";
+ return \"xxpermdi %x0,%x2,%x1,1\";
else if (INTVAL (operands[3]) == 1)
- return \"xxpermdi %x0,%x2,%x1,0\";
+ return \"xxpermdi %x0,%x1,%x2,0\";
else
gcc_unreachable ();
}
Index: gcc/testsuite/gcc.target/powerpc/pr52457.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr52457.c (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr52457.c (revision 0)
@@ -0,0 +1,34 @@
+/* { dg-do run { target { powerpc*-*-linux* } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
+/* { dg-require-effective-target vsx_hw } */
+/* { dg-options "-O1 -mcpu=power7" } */
+
+extern void abort (void);
+
+typedef long long T;
+typedef T vl_t __attribute__((vector_size(2 * sizeof (T))));
+
+vl_t
+buggy_func (T x)
+{
+ vl_t w;
+ T *p = (T *)&w;
+ p[0] = p[1] = x;
+ return w;
+}
+
+int
+main(void)
+{
+ vl_t rval;
+ T *pl;
+
+ pl = (T *) &rval;
+ rval = buggy_func (2);
+
+ if (pl[0] != 2 || pl[1] != 2)
+ abort ();
+
+ return 0;
+}