public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix shufpd operands (PR target/46880)
@ 2010-12-21 22:33 Jakub Jelinek
  2010-12-21 22:50 ` Uros Bizjak
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-12-21 22:33 UTC (permalink / raw)
  To: Uros Bizjak, H.J. Lu; +Cc: gcc-patches

Hi!

In these two insns, shufpd insn is used in an alternative which has
constraint 0 on operand %2 and constraint x on operand %1, so it
is obviously wrong to use operand %2 as source operand, because
that's the same register as %0 and shuftpd $2, %xmm0, %xmm0
(or any other where src == dst) is a nop).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR target/46880
	* config/i386/sse.md (sse2_loadlpd, sse2_movsd): Fix shufpd source
	operand.

	* gcc.target/i386/pr46880.c: New test.

--- gcc/config/i386/sse.md.jj	2010-12-09 11:12:48.000000000 +0100
+++ gcc/config/i386/sse.md	2010-12-21 15:15:16.000000000 +0100
@@ -4990,7 +4990,7 @@ (define_insn "sse2_loadlpd"
    movsd\t{%2, %0|%0, %2}
    movlpd\t{%2, %0|%0, %2}
    movsd\t{%2, %0|%0, %2}
-   shufpd\t{$2, %2, %0|%0, %2, 2}
+   shufpd\t{$2, %1, %0|%0, %1, 2}
    movhpd\t{%H1, %0|%0, %H1}
    #
    #
@@ -5067,7 +5067,7 @@ (define_insn "sse2_movsd"
    movsd\t{%2, %0|%0, %2}
    movlpd\t{%2, %0|%0, %2}
    movlpd\t{%2, %0|%0, %2}
-   shufpd\t{$2, %2, %0|%0, %2, 2}
+   shufpd\t{$2, %1, %0|%0, %1, 2}
    movhps\t{%H1, %0|%0, %H1}
    movhps\t{%1, %H0|%H0, %1}"
   [(set_attr "type" "ssemov,ssemov,ssemov,sselog,ssemov,ssemov")
--- gcc/testsuite/gcc.target/i386/pr46880.c.jj	2010-12-21 15:33:40.000000000 +0100
+++ gcc/testsuite/gcc.target/i386/pr46880.c	2010-12-21 15:36:26.000000000 +0100
@@ -0,0 +1,28 @@
+/* PR target/46880 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-strict-aliasing -msse2" } */
+/* { dg-require-effective-target sse2_runtime } */
+
+typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef double (*T)[2];
+
+static __attribute__ ((noinline, noclone)) __m128d
+foo (__m128d c, __m128d d)
+{
+  T cp = (T) &c;
+  T dp = (T) &d;
+  __m128d e = { (*cp)[1], (*dp)[1] };
+  return e;
+}
+
+int
+main ()
+{
+  __m128d c = { 1.0, 2.0 };
+  __m128d d = { 3.0, 4.0 };
+  union { __m128d x; double d[2]; } u;
+  u.x = foo (c, d);
+  if (u.d[0] != 2.0 || u.d[1] != 4.0)
+    __builtin_abort ();
+  return 0;
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix shufpd operands (PR target/46880)
  2010-12-21 22:33 [PATCH] Fix shufpd operands (PR target/46880) Jakub Jelinek
@ 2010-12-21 22:50 ` Uros Bizjak
  0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2010-12-21 22:50 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: H.J. Lu, gcc-patches

On Tue, Dec 21, 2010 at 9:52 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> In these two insns, shufpd insn is used in an alternative which has
> constraint 0 on operand %2 and constraint x on operand %1, so it
> is obviously wrong to use operand %2 as source operand, because
> that's the same register as %0 and shuftpd $2, %xmm0, %xmm0
> (or any other where src == dst) is a nop).
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2010-12-21  Jakub Jelinek  <jakub@redhat.com>
>
>        PR target/46880
>        * config/i386/sse.md (sse2_loadlpd, sse2_movsd): Fix shufpd source
>        operand.
>
>        * gcc.target/i386/pr46880.c: New test.

OK.

Thanks,
Uros.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-21 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-21 22:33 [PATCH] Fix shufpd operands (PR target/46880) Jakub Jelinek
2010-12-21 22:50 ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).