This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: missed optimization, would be very helpful
- To: Zack Weinberg <zack at rabi dot columbia dot edu>
- Subject: Re: missed optimization, would be very helpful
- From: Andreas Schwab <schwab at LS5 dot informatik dot uni-dortmund dot de>
- Date: 06 Jan 1999 10:56:04 +0100
- Cc: egcs at egcs dot cygnus dot com
- References: <199812312032.PAA05614@rabi.phys.columbia.edu>
Zack Weinberg <zack@rabi.columbia.edu> writes:
|> In a loop of the form
|>
|> while (condition) (*int_ptr)++;
|>
|> gcc generates a read-mod-write cycle to the memory location *int_ptr at each
|> iteration of the loop. Modern chips really don't like that; I got a ~30%
|> speedup on one piece of code by rewriting it to bump a register and write
|> the memory location at the end. The pointer isn't volatile, so I believe
|> there is nothing stopping gcc from doing this optimization.
|>
|> This is egcs-1.1.1; it might've been fixed more recently but I can't test
|> that since the Dec 24 CVS is unreliable on my system.
|>
|> (If anyone wants an example, look at cpplib.c:adjust_position.)
This is a bad example, because linep and colp may alias each other, and a
char * can alias everything.
--
Andreas Schwab "And now for something
schwab@issan.cs.uni-dortmund.de completely different"
schwab@gnu.org