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]

Patch for const-ifying RTL checking macros, yields speedup


The code below is activated when configuring with RTL checking.  This
patch const-ifies the variables set in those macros.

Interestingly, the result is that when RTL checking is enabled, one
gets a ~30K code size reduction (on solaris2.7.)  Also I tried timing
compiles of insn-attrtab.c and patched gcc compiled it consistently
3.8% more quickly when compared to a baseline gcc!

I installed this as obvious on the trunk, however since I do lots of
RTL checking on the branch (with multiple passes in target_board), I
was wistfully hoping that I could put it on the branch also.  (I get
the same improvement results there too.)

You won't see any improvement (or even use this code) if you don't
enable RTL checking.  So its really safe.

		Thanks,
		--Kaveh


2002-03-31  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* rtl.h (RTL_CHECK1, RTL_CHECK2, RTL_CHECKC1, RTL_CHECKC2,
	RTVEC_ELT): Const-ify.

diff -rup orig/egcc-CVS20020331/gcc/rtl.h egcc-CVS20020331/gcc/rtl.h
--- orig/egcc-CVS20020331/gcc/rtl.h	Thu Mar 21 07:00:27 2002
+++ egcc-CVS20020331/gcc/rtl.h	Sun Mar 31 20:25:09 2002
@@ -264,8 +264,8 @@ struct rtvec_def {
 /* The bit with a star outside the statement expr and an & inside is
    so that N can be evaluated only once.  */
 #define RTL_CHECK1(RTX, N, C1) __extension__				\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     enum rtx_code _code = GET_CODE (_rtx);				\
+(*({ rtx const _rtx = (RTX); const int _n = (N);			\
+     const enum rtx_code _code = GET_CODE (_rtx);			\
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
 				__FUNCTION__);				\
@@ -275,8 +275,8 @@ struct rtvec_def {
      &_rtx->fld[_n]; }))
 
 #define RTL_CHECK2(RTX, N, C1, C2) __extension__			\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     enum rtx_code _code = GET_CODE (_rtx);				\
+(*({ rtx const _rtx = (RTX); const int _n = (N);			\
+     const enum rtx_code _code = GET_CODE (_rtx);			\
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
 				__FUNCTION__);				\
@@ -287,22 +287,22 @@ struct rtvec_def {
      &_rtx->fld[_n]; }))
 
 #define RTL_CHECKC1(RTX, N, C) __extension__				\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
+(*({ rtx const _rtx = (RTX); const int _n = (N);			\
      if (GET_CODE (_rtx) != (C))					\
        rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,		\
 			       __FUNCTION__);				\
      &_rtx->fld[_n]; }))
 
 #define RTL_CHECKC2(RTX, N, C1, C2) __extension__			\
-(*({ rtx _rtx = (RTX); int _n = (N);					\
-     enum rtx_code _code = GET_CODE (_rtx);				\
+(*({ rtx const _rtx = (RTX); const int _n = (N);			\
+     const enum rtx_code _code = GET_CODE (_rtx);			\
      if (_code != (C1) && _code != (C2))				\
        rtl_check_failed_code2 (_rtx, (C1), (C2), __FILE__, __LINE__,	\
 			       __FUNCTION__); \
      &_rtx->fld[_n]; }))
 
 #define RTVEC_ELT(RTVEC, I) __extension__				\
-(*({ rtvec _rtvec = (RTVEC); int _i = (I);				\
+(*({ rtvec const _rtvec = (RTVEC); const int _i = (I);			\
      if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec))				\
        rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__,	\
 				  __FUNCTION__);			\


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