[x86 PATCH]: RETURN_IN_MEMORY vs. i386's type_natural_mode

Mark Mitchell mark@codesourcery.com
Wed Aug 2 23:19:00 GMT 2006


Roger Sayle wrote:

> The issue concerns the x86 backend's handling of ABIs that return vector
> modes such as V8QI or V2SI on CPU targets without MMX (likewise SSE).
> Conceptually, a subtarget has one of two choices, it can either force
> the result to be returned in memory, or it can treat an 8 byte result
> as it would a DImode result, and return it in eax:edx.

Thanks for the detailed analysis.  A priori, I'd suggest that it's
probably better to return the value in registers, just to avoid possibly
unnecessary memory traffic.  The patch that provides that functionality
also has the nice property that it fixes the problem in a single place.
 Furthermore, there's nothing to prevent an individual ABI from forcing
the value to memory, if that's what it wants to do.  (I suppose that for
Solaris, it would be interesting to know what Sun's compiler does in
this case -- if it provides any mechanism for vector types.)

>     /* 8-byte vector modes in %mm0. See ix86_return_in_memory for where
> !      we normally prevent this case when mmx is not available.  However
> !      some ABIs may require the result to returned like DImode.  */

"be returned like"

>     /* 16-byte vector modes in %xmm0.  See ix86_return_in_memory for where
>        we prevent this case when sse is not available.  */
>     if (mode == TImode || (VECTOR_MODE_P (mode) && GET_MODE_SIZE (mode) == 16))
> !     return TARGET_SSE ? FIRST_SSE_REG : 0;

Since you changed the other comment, I guess you should change this one
too.  Or just put both conditionals next to each other with one
uber-comment:

  /* 8-byte vector modes go in %mm0; 16-byte vector modes go in xmm0.
See...  */

I'm going to conditionally approve this patch -- but please allow 48
hours for an x86 maintainer to object.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list