User account creation filtered due to spam.

Bug 14326 - boehm-gc hardcodes to 3DNow! prefetch for x86_64
Summary: boehm-gc hardcodes to 3DNow! prefetch for x86_64
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.3
: P2 enhancement
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-27 17:16 UTC by H.J. Lu
Modified: 2004-04-21 15:29 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64_intel-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-02-27 17:20:46


Attachments
A patch to use __builtin_prefetch (362 bytes, patch)
2004-02-27 17:18 UTC, H.J. Lu
Details | Diff
A patch to use asm statement (423 bytes, patch)
2004-02-27 17:51 UTC, H.J. Lu
Details | Diff
A new patch to use __builtin_prefetch (425 bytes, patch)
2004-03-01 05:26 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2004-02-27 17:16:01 UTC
boehm-gc/include/private/gcconfig.h has

#       define PREFETCH(x) \
          __asm__ __volatile__ ("       prefetch        %0": : "m"(*(char *)(x)))
#       define PREFETCH_FOR_WRITE(x) \
          __asm__ __volatile__ ("       prefetchw       %0": : "m"(*(char *)(x)))

It doesn't work with Intel ia32e processors.
Comment 1 H.J. Lu 2004-02-27 17:18:06 UTC
Created attachment 5812 [details]
A patch to use __builtin_prefetch

This patch uses __builtin_prefetch instead of asm statement.
Comment 2 Andrew Pinski 2004-02-27 17:20:45 UTC
Confirmed, note that since x86_64 was only AMD64 until lately this was right, also note I think Intel 
should implement 3DNow and get over this crazy semi compatiablity crap.
Comment 3 Jeff Sturm 2004-02-27 17:38:37 UTC
__builtin_prefetch may be fine for GCC's copy of the GC, however the upstream
version will need another solution as it is sometimes used with non-GCC compilers.

(There aren't many compilers available yet for x86-64, but I'd guess icc, msvc
and others will appear before long.)
Comment 4 Andreas Schwab 2004-02-27 17:46:33 UTC
Inline asm is already GCC-only, so this would not make it worse. 
Comment 5 H.J. Lu 2004-02-27 17:51:22 UTC
Created attachment 5813 [details]
A patch to use asm statement

This patch uses asm statement. But I agree it may only
work with gcc.
Comment 6 Hans Boehm 2004-02-27 18:37:37 UTC
I'd be inclined to use __builtin_prefetch for both the X86_64 and I386 cases.  
That gets rid of some obscure configuration options for the GC.

This should be guarded by a #ifdef __GNUC__ .  The current assembly code isn't 
going to work for a non-gcc compiler anyway.  (This may still break the Intel 
compiler.  If so, we'll fix it then.)

I assume gcc does the right thing for __builtin_prefetch depending on the 
command line arguments, i.e. generates nothing by default?

I would like to see the I386 and X86_64 cases handled identically, since the 
underlying mess is now unfortunately the same.

If AMD and Intel can't work this out, we should eventually include two near 
clones of the marker code, one using each version, and choose at run-time.  But 
that's real work.

Hans
Comment 7 H.J. Lu 2004-02-27 18:55:06 UTC
__builtin_prefetch will generate the appropriate instruction for
target CPU.
Comment 8 H.J. Lu 2004-03-01 05:26:51 UTC
Created attachment 5824 [details]
A new patch to use __builtin_prefetch

This patch uses __builtin_prefetch only if gcc 3.0 or above is used.
Comment 9 Hans Boehm 2004-04-06 17:30:22 UTC
The third patch looks fine to me.  Please check it in.  I put it in the 
upstream source.

Sorry about losing track of this.

Hans
Comment 10 CVS Commits 2004-04-21 15:17:52 UTC
Subject: Bug 14326

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	hjl@gcc.gnu.org	2004-04-21 15:17:48

Modified files:
	boehm-gc       : ChangeLog 
	boehm-gc/include/private: gcconfig.h 

Log message:
	2004-04-21  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR target/14326
	Backport from mainline:
	
	* include/private/gcconfig.h (PREFETCH): Use __builtin_prefetch
	for gcc >= 3.0.
	(PREFETCH_FOR_WRITE): Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/boehm-gc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.170.2.3&r2=1.170.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/boehm-gc/include/private/gcconfig.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.35.6.1&r2=1.35.6.2

Comment 11 Andrew Pinski 2004-04-21 15:29:14 UTC
Fixed in 3.4.1.