[m-rev.] diff: regparm(2)

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Oct 14 13:19:50 AEST 2002


Estimated hours taken: 0.25
Branches: main

runtime/mercury_std.h:
	Use regparm(2) instead of regparm(3), since regparm(3) can inhibit
	GCC's tail recursion optimization.

Workspace: /mnt/ceres/home/ceres/fjh/mercury
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.22
diff -u -d -r1.22 mercury_std.h
--- runtime/mercury_std.h	2002/09/16 19:03:56	1.22
+++ runtime/mercury_std.h	2002/10/14 03:17:07
@@ -214,9 +214,16 @@
 ** or adding support for other C compilers or other processors)
 ** should be reflected in the mangled grade name produced by
 ** runtime/mercury_grade.h.
+**
+** It might be slightly more efficient to use __regparm__(3) rather than
+** __regparm__(2), but GCC won't do tail-call optimization for calls via
+** function pointers if we use __regparm__(3), since there may be no spare
+** caller-save registers to hold the function pointer.  Tail call
+** optimization is more likely to be important than squeezing the last 1%
+** in performance.
 */
 #if defined(MR_USE_REGPARM) && defined(__GNUC__) && defined(__i386__)
-  #define MR_CALL __attribute__((__stdcall__, __regparm__(3)))
+  #define MR_CALL __attribute__((__stdcall__, __regparm__(2)))
 #else
   #define MR_CALL
 #endif

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list