This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: ivopts improvement
- From: Tom de Vries <vries at codesourcery dot com>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>, Richard Guenther <richard dot guenther at gmail dot com>, gcc-patches at gcc dot gnu dot org, Bernd Schmidt <bernds at codesourcery dot com>, Maxim Kuvyrkov <maxim at codesourcery dot com>
- Date: Fri, 04 Mar 2011 14:57:40 +0100
- Subject: Re: ivopts improvement
- References: <4D6B6DB9.7050302@codesourcery.com> <4D6B7AFD.6000201@gnu.org> <4D6BAF92.3030707@codesourcery.com> <4D6BB48A.9090003@gnu.org> <AANLkTi=-0CJ=W7JXYs9sBZw7ic6W0SYU9tmJVr+YHh5J@mail.gmail.com> <20110228181222.GA24295@kam.mff.cuni.cz> <4D6EBE2A.10002@codesourcery.com> <4D6F550B.9060400@gnu.org> <4D6FA591.6060604@codesourcery.com> <4D7096A3.3020505@gnu.org>
On 03/04/2011 08:37 AM, Paolo Bonzini wrote:
> On 03/03/2011 03:28 PM, Tom de Vries wrote:
>> reg-tested on x86_64. Better?
>
> Yes, very much so
Great. Thanks for the review.
> (talking about patch 6.5; the other one is an
> optimization but not essential based on the new comments).
>
> Just one question: what happens if the COND_EXPR is indeed turned into a
> MAX_EXPR? Is it a missed optimization?
It is. It will take some effort to get cost calculation for MAX_EXPR ok.
One additional problem (beside costs) that I observed also might need
fixing: a new bound (containing a MAX_EXPR) is generated for an inner
loop. The new bound is outer loop invariant. The MAX_EXPR however
expands into control flow, and is not hoisted out of the outer loop,
while the rest of the bound calculation is.
> Is it because of overflow that
> you aren't _always_ creating a MAX_EXPR directly?
Indeed. The COND_EXPR created for my example is:
...
(i + 1 <= n) ? (~i + n) : 0
...
where i and n are unsigned int.
simplified:
...
(i + 1 <= n) ? (n - (i + 1)) : 0
...
The condition i + 1 <= n precisely states the cases when n - (i + 1)
does not underflow.
Thanks,
- Tom