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: [RFC] Small compiler speedup?


Op wo 09-04-2003, om 01:13 schreef Andrew Pinski:
> A switch statement is slower than a just one memory access.

Maybe I wasn't clear.  I mean to do the switch thing just to initialize
the is_statement_code array.  The whole point is to get rid of the
function call, the conditional branch, the indirect call and everything
else that can be done a bit faster.

> Even though you are redefining all tree codes.

Well, I have two more objection against redefining all tree codes:
1) The whole statement_code_p is C-family specific.  It deals with
*_STMT tree codes which are C/C++ specific.  Redefining DEFTREECODE
burdens all front ends.  Not good thinks me.
2) The whole idea of distinguishing between statements and expressions
is language specific.  Which is why in GENERIC/GIMPLE (tree-ssa)
everything is an expression.

Well OK, that was actually just one objection...

I do agree that defining it with DEFTREECODE would look somewhat
cleaner.

> The current way is bad since it includes an indirect call
> every time you want to find out if the tree is a statement
> (and not a C/Objective-C statement).
> You are setting which tree codes are statements once and you
> would be using a cache not having to go through that much code.


> 
> On Tuesday, Apr 8, 2003, at 18:49 US/Eastern, Steven Bosscher wrote:
> 
> > Op di 08-04-2003, om 23:52 schreef Zack Weinberg:
> >> This looks like a decent improvement.  For the initialization
> >> problems, can I suggest you add an argument to the DEFTREECODE macro?
> >
> > Hmmm, redefining all > 270 tree codes to say that 25 of them (for C++)
> > are statements?  There's got to be a better way.
> >
> > I was thinking of defining something like this in c-common.h:
> >
> > #define case_c_common_stmt_code						\
> >   case CLEANUP_STMT:	case EXPR_STMT:		case COMPOUND_STMT:	\
> >   case DECL_STMT:	case IF_STMT:		case FOR_STMT:		\
> >   case WHILE_STMT:	case DO_STMT:		case RETURN_STMT:	\
> >   case BREAK_STMT:	case CONTINUE_STMT:	case SCOPE_STMT:	\
> >   case SWITCH_STMT:	case GOTO_STMT:		case LABEL_STMT:	\
> >   case ASM_STMT:	case FILE_STMT:		case CASE_LABEL
> >
> > and then just have:
> >
> > 	switch(code)
> > 	  {
> > 	  case_c_common_stmt_code:
> > 	  /* Language specific tree codes go down here.  */
> > 	  /* Somehow set is_statement_code to true.  */
> >
> > 	  default:
> > 	  /* Somehow set to false.  */
> > 	  }
> >
> > Not that great either (still the loop), but at least this moves the 
> > list
> > back to just one place instead of two.  The patch duplicates the list 
> > in
> > cp/lex.c (which is quite a weird place for cxx_init BTW) and c-lang.c, 
> > I
> > don't think that is a good idea.
> >
> > Greetz
> > Steven
> >
> >
> >
> >



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