[Bug target/91841] vector_size(8) passes MMX register without emms cleanup

hjl.tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Sep 23 15:47:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91841

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Matthias Kretz (Vir) from comment #2)
> Ah, because of:
> 
> typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));
> 
> ? Too be pedantic only `int [[gnu::vector_size(8)]]` equals __m64. But I see
> your point.
> 
> I guess clang interprets the optional nature of __m64 to mean that they can
> pass vector_size(8) objects on the stack? (aka, there's no __m64 here)
> 
> But then 2.2.1 says "Therefore, every function that uses the MMX registers
> is required to issue an emms or femms instruction after using MMX registers,
> before returning or calling another function."

We can add "except when MMX registers are used for parameter passing or
return value".  But since MMX support in GCC is very limited, it is
unwise to use MMX registers in GCC, especially when they are used
for parameter passing or return value.

> This is in contradiction to Table 2.4 which requires __m64 to be returned
> via %mm0. Calling emms before ret would invalidate the return value. I.e.
> the ABI must require callers of functions that return via %mm0 to call emms.
> 
> Am I reading this wrong, or is the ABI broken here?
> 
> Note, I am fine with a wontfix. Just want to be extra clear about the design
> decision here.


More information about the Gcc-bugs mailing list