I was recompiling my MMX code on GCC 4 and was surprised to see that none of 
the moves from general regs to MMX (and other way around) were happening 
directly but through intermediate memory location and I could not find a 
combination of optimization options which would disable this behaviour.

I tried to find out what is causing this and this is what I found:

gcc/config/i386/i386.c:
int ix86_secondary_memory_needed (enum reg_class class1, enum reg_class 
class2, enum machine_mode mode, int strict)
...

/* ??? This is a lie. We do have moves between mmx/general, and for mmx/sse2.
But by saying we need secondary memory we discourage the register allocator
from using the mmx registers unless needed. */

if (MMX_CLASS_P (class1) != MMX_CLASS_P (class2)) return true;
... 

If I comment out that "if" line, mmx register assignments from general 
registers will work.
Should the requirement of using secondary memory to move MMX registers between 
general regs be relaxed ?
I do not see the point why one should discourage the register allocator from 
using mmx registers, move through memory is clearly inefficent and enlarges 
resulting code (if the function containing moves is inlined in several places, 
even more so).
I'll attach my source and assembly output from GCC 4.1.0 (30.08.2005 CVS HEAD) 
vs GCC 3.4.4, these are short.

-- 
           Summary: Moves from general to MMX registers use unnecessary
                    secondary memory
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vahur dot sinijarv at cydonia dot ee
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-mingw32
  GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32


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

Reply via email to