This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Disable old loop optimizer
- From: Paul Schlie <schlie at comcast dot net>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: Mark Mitchell <mark at codesourcery dot com>,<gcc-patches at gcc dot gnu dot org>,Daniel Berlin <dberlin at dberlin dot org>,Jeffrey A Law <law at redhat dot com>
- Date: Wed, 13 Apr 2005 12:22:05 -0400
- Subject: Re: [patch] Disable old loop optimizer
> Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
>> 2) loop reversal (i.e. replacing "for (i = 0; i < n; i++) a[i]=i;" with
>> "for (i = n - 1; i >= 0; i--) a[i]=i;", thus causing us to compare
>> with zero instead of arbitrary bound, and possibly shorten the life
>> range of n). Should be trivial within linear-transform framework,
>> the major problem is to decide when it is really useful. the major
>> problem is to decide when it is really useful.
It should be considered to be universally useful: as comparing a value
against a constant 0 is never more expensive than comparing it against an
arbitrary constant, and most typically less expensive because a constant
value of 0 is typically both easier to generate if needed as a register
value, and/or directly in-lined into a comparison instruction as a small
constant when necessary; and/or enables architectures which save implied
logical or arithmetic result comparisons against zero in a cc-register,
to potentially avoid the necessary of an explicit comparison altogether.
(so it would seem to never be worse, and typically always better.)