This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: x86/MMX/SSE shift by immediate
- From: Stuart Hastings <stuart at apple dot com>
- To: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>, Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Jan 2004 14:36:13 -0800
- Subject: Re: x86/MMX/SSE shift by immediate
- References: <1F5C0B7C-2D05-11D8-8396-000A95A83B3C@apple.com> <20031218222508.GE10588@redhat.com> <FB5CAAB7-40B3-11D8-84FC-000A95A83B3C@apple.com> <20040107101305.GC21007@redhat.com>
Stuart Hastings <stuart@apple.com> writes:
#define NOINLINE __attribute__ ((noinline))
void nowhere (const char *) NOINLINE;
void
nowhere (const char *x)
{
}
You need NOINLINE below here, too, or the attribute will be trampled
over, and unit-at-a-time will inline "nowhere". (I think there's a PR
about this, but it is how things are currenly.)
--
Falk
Inline nowhere, eh? That's exactly what I wanted.
Ahem. ;-)
O.K., serious now. I didn't know about this issue with unit-at-a-time;
thank-you for pointing this out. Fixed in the updated patch attached
below.
On Jan 7, 2004, at 2:13 AM, Richard Henderson wrote:
On Tue, Jan 06, 2004 at 05:51:16PM -0800, Stuart Hastings wrote:
/* Gratuitous use of a static forces save/restore of PIC register.
It should be O.K. to clobber the PIC register in this routine.
*/
nowhere ("fubar");
This only works for -fpic/-fPIC,
True, and it's probably unnecessary for the non-PIC case.
__asm__ ("cpuid" : "=a" (fl1) : "0" (0) : /* "ebx", "ecx", "edx",
*/ "cc");
Otherwise this really does kill ebx, and it needn't be restored.
I'm not sure if you're suggesting a change to the code, or just to the
comments (?). Maybe I would understand better if I were reading this
at 2AM. ;-)
Yes, both of the CPUID instructions here kill %eax, %ebx, %ecx, and
%edx. However, if I admit as much in the __asm__, and I compile with
-fPIC (default on Darwin/x86), GCC stops here with the diagnostic
/Volumes/sandbox/stuart/gcc.fsf/gcc/testsuite/gcc.dg/i386-cpuid.h:39:
error: PIC register `ebx' clobbered in `asm'
Ergo, I chose to lie to GCC about the CPUID instruction. :-( I really
dislike doing this; sleazy tricks like this usually cause maintenance
headaches later on (e.g. if GCC gets smarter about the PIC register, we
could and should describe CPUID correctly here). Do you know a better
way?
r~
To reiterate, I've run this testcase with DejaGnu on Darwin/x86, where
-fPIC is the default, and by hand on Debian GNU/Linux, where it's not.
I haven't tried it on a P3, but not on any hardware lacking MMX. I've
also revised some of the comments, and removed some dead local
variables. You've already approved the original patch to i386.md; now
I'm just trying to get the testcase right, so I may commit everything
simultaneously.
O.K. to commit ?
stuart hastings
Apple Computer
Attachment:
gcc.fsf.diffs.txt
Description: Text document
Attachment:
i386-sse-5.c
Description: Text document
Attachment:
i386-cpuid.h
Description: Text document