This is the mail archive of the gcc-bugs@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]

[Bug target/43743] Dumb use of SSE regs for MMX operation



------- Comment #6 from ubizjak at gmail dot com  2010-04-19 18:22 -------
(In reply to comment #4)

> I've recommended that the compile the code in different source files, although
> that is apparently complex for some reason.  In any case, this seems to me like
> a clear bug: using MMX intrinsics should cause the use of MMX registers.  One
> simple approach here would be to avoid using the same define_insn for both MMX
> and SSE.

Please note that the problem is NOT in the mmx_punpcklbw insn pattern, but in
mmx_concatv2si pattern. Currently, the mmx_concatv2si is defined as:

(define_insn "*mmx_concatv2si"
  [(set (match_operand:V2SI 0 "register_operand"     "=y,y")
        (vec_concat:V2SI
          (match_operand:SI 1 "nonimmediate_operand" " 0,rm")
          (match_operand:SI 2 "vector_move_operand"  "ym,C")))]
  "TARGET_MMX && !TARGET_SSE"
  "@
   punpckldq\t{%2, %0|%0, %2}
   movd\t{%1, %0|%0, %1}"
  [(set_attr "type" "mmxcvt,mmxmov")
   (set_attr "mode" "DI")])

and its SSE+ counterpart is *vec_concatv2si_{sse,sse2,sse4_1,avx}:

(define_insn "*vec_concatv2si_sse"
  [(set (match_operand:V2SI 0 "register_operand"     "=x,x,*y,*y")
        (vec_concat:V2SI
          (match_operand:SI 1 "nonimmediate_operand" " 0,m, 0,*rm")
          (match_operand:SI 2 "reg_or_0_operand"     " x,C,*y,C")))]
  "TARGET_SSE"
  "@
   unpcklps\t{%2, %0|%0, %2}
   movss\t{%1, %0|%0, %1}
   punpckldq\t{%2, %0|%0, %2}
   movd\t{%1, %0|%0, %1}"
  [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
   (set_attr "mode" "V4SF,V4SF,DI,DI")])

Removing "*" in front of "y" will solve your problem, but gcc will allocate MMX
register behind your back during construction of V4SI vectors (in SSE
registers!). The only solution is to separate MMX code into its own file and
compile it with -mno-sse on 32bit targets. Also, do not forget to use
__bultin_emms, otherwise you will block x87 FP registers from the moment MMX
registers are touched.

As far as 64bit targets are concerned, do not use MMX there, ever.

You can find plenty of "unwanted MMX reg used instead of SSE reg" bug reports
in the Bugzilla, and this was really a big problem some time ago.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43743


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