diff mbox

[rs6000,trunk,4.7,4.6,4.5] Fix PR52457, wrong code for -O1 -m32 -mcpu=power7

Message ID 1330703856.29904.3.camel@otta
State New
Headers show

Commit Message

Peter Bergner March 2, 2012, 3:57 p.m. UTC
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.

Comments

David Edelsohn March 2, 2012, 4:19 p.m. UTC | #1
On Fri, Mar 2, 2012 at 10:57 AM, Peter Bergner <bergner@vnet.ibm.com> wrote:
> 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.

Okay everywhere, but please make sure that Richi and Jakub are okay
with the patch for GCC 4.7.

Thanks, David
Jakub Jelinek March 2, 2012, 5:15 p.m. UTC | #2
On Fri, Mar 02, 2012 at 11:19:15AM -0500, David Edelsohn wrote:
> On Fri, Mar 2, 2012 at 10:57 AM, Peter Bergner <bergner@vnet.ibm.com> wrote:
> > 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.
> 
> Okay everywhere, but please make sure that Richi and Jakub are okay
> with the patch for GCC 4.7.

This is ok for 4.7.0.

	Jakub
Peter Bergner March 2, 2012, 6:36 p.m. UTC | #3
On Fri, 2012-03-02 at 11:19 -0500, David Edelsohn wrote:
> On Fri, Mar 2, 2012 at 10:57 AM, Peter Bergner <bergner@vnet.ibm.com> wrote:
> > 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?
> >
> >        * gcc/config/rs6000/vsx.md (vsx_set_<mode>): Reorder operands.
> >        * gcc/testsuite/gcc.target/powerpc/pr52457.c: New test.
> 
> Okay everywhere, but please make sure that Richi and Jakub are okay
> with the patch for GCC 4.7.

Ok, I have committed the patch to trunk and the 4.7 branch given Jakub's
ok in his email.  I'll commit the patch to the 4.6 and 4.5 branches once
my testing has completed.  Thanks.


Peter
diff mbox

Patch

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;
+}