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

Re: x86/MMX/SSE shift by immediate


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


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