This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[x86] do not issue invalid vec_select from V2DI


This is related with Red Hat Bugzilla 171689,
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=171689

The problem is that, when compiling a V2DI multiply with -msse2 or
-msse3 on 32-bit x86, GCC 4.0 used to emit an instruction to extract
the second element of the vector, even though it has no pattern to
handle this case.  V2DF arrays are handled for extraction of both
elemtn, but V2DI can only extract the first element.

In mainline, we emit a significantly different piece of code that
avoids the need for extracting the array elements, thus not triggering
the bug.  But I don't see that the bug has actually been fixed, it's
just harder (perhaps impossible?) to expose it.

Here's a reduced testcase to trigger the bug:

Attachment: gcc_vector_bug.c
Description: Binary data


Here's the patch for 4.0 that fixes it, that still applies perfectly
to mainline, where I couldn't find any changes in sse.md that might
have fixed the problem in a different way.  Ok for trunk, 4.1 and 4.0,
or is there a better way to extract the second element of a V2DI?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/i386/i386.c (ix86_expand_vector_extract) <V2DImode>: Do
	not use vec_select to extract the second element.

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c.orig	2005-12-17 17:51:59.000000000 -0200
+++ gcc/config/i386/i386.c	2005-12-17 18:00:21.000000000 -0200
@@ -16997,8 +16997,11 @@
 	break;
       /* FALLTHRU */
 
-    case V2DFmode:
     case V2DImode:
+      use_vec_extr = (elt == 0);
+      break;
+
+    case V2DFmode:
       use_vec_extr = true;
       break;
 

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]