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.
Created attachment 5812 [details] A patch to use __builtin_prefetch This patch uses __builtin_prefetch instead of asm statement.
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.
__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.)
Inline asm is already GCC-only, so this would not make it worse.
Created attachment 5813 [details] A patch to use asm statement This patch uses asm statement. But I agree it may only work with gcc.
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
__builtin_prefetch will generate the appropriate instruction for target CPU.
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.
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
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
Fixed in 3.4.1.