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: make genattrtab generate smaller code


 > This patch moves all the get_attr_xxx calls inside the if()s to the
 > front of the function by caching the results, in order to save several
 > hundred function calls, i.e. like:
 > 
 > enum attr_x get_attr_lala (rtx insn) {
 > enum attr_memory attr_memory = get_attr_memory(insn);
 > switch (recog_memoized(insn)) {
 > case xxx:
 >   if (bla && attr_memory == XXX) {
 >   } else if (blubb && attr_memory == XXX) {
 >   } else if (bla2 && attr_memory == YYY) {
 >   } else {
 >   }

Cool.  I was wondering if we could get GCC to do some of this
automatically by adding the "const" or "pure" function attribute to
get_attr_memory() and like functions in the insn-* generated files.
If so, then GCC should optimize this for us (and in perhaps more cases
than with your patch alone.)


 > I also experimented with merging the multiple test on
 > which_alternative to use '&', ala
 > 
 >   if ((which_alternative == 1) || (which_alternative == 2))
 > -->
 >   if ((1 << which_alternative) & 0x6)
 > 
 > but this didn't result in smaller or faster code. 
 > 

IIRC, not too long ago someone posted a patch to add this optimization
to GCC across the board.  I don't recall if it went in or not, nor do
I recall the URL.  But it would be nice to have the compiler
automatically do this for us too. :-)

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


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