[x86] do not issue invalid vec_select from V2DI

Alexandre Oliva aoliva@redhat.com
Wed Jan 4 23:05:00 GMT 2006


On Dec 22, 2005, Richard Henderson <rth@redhat.com> wrote:

> On Sat, Dec 17, 2005 at 06:30:33PM -0200, Alexandre Oliva wrote:
>> 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.

> I'm thinking we should simply add some new patterns.

That sounds even better.  I simply assumed there just wasn't a better
way to do it.  Now, as I get more acquainted with the SSE extensions,
I see it is, but I don't see why you've suggested this:

> (define_insn "*vec_extractv2di_1"
>   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,x,x")
> 	(vec_select:DI
> 	  (match_operand:V2DI 1 "nonimmediate_operand" "x,0,o")
> 	  (parallel [(const_int 1)])))]
>   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
> {
>   switch (which_alternative)
>     {
>     case 0:
>       return "movhps\t{%1, %0|%0, %1}";
>     case 1:
>       operands[1] = GEN_INT (4);
>       return "psrldq\t{%1, %0|%0, %1}";
>     case 2:
>       return "#";
>     default:
>       gcc_unreachable ();
>     }
> })

instead of the simpler (and SSE1-compatible, I hope, although this is
all new to me and I haven't found reliable docs on differences between
SSE1 and SSE2 so far):

(define_insn "*vec_extractv2di_1"
  [(set (match_operand:DI 0 "nonimmediate_operand" "=m,x,x")
	(vec_select:DI
	  (match_operand:V2DI 1 "nonimmediate_operand" "x,x,o")
	  (parallel [(const_int 1)])))]
  "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))""
  "@
   movhpd\t{%1, %0|%0, %1}
   movhlpd\t{%1, %0|%0, %1}
   movlpd\t{%H1, %0|%0, %H1}"
  [(set_attr "type" "ssemov")
   (set_attr "mode" "V1DF,V2DF,DF")])

What am I missing?

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



More information about the Gcc-patches mailing list