This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] [RFC] loop index promotion pass
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: Richard Guenther <richard dot guenther at gmail dot com>
- Cc: Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 20 May 2009 06:39:00 -0700
- Subject: Re: [PATCH] [RFC] loop index promotion pass
- References: <20090423161719.GV22588@codesourcery.com> <firstname.lastname@example.org> <20090424184303.GZ22588@codesourcery.com> <email@example.com> <4A133750.firstname.lastname@example.org> <email@example.com>
On Wed, May 20, 2009 at 10:51:05AM +0200, Richard Guenther wrote:
> On Wed, May 20, 2009 at 12:48 AM, Mark Mitchell <firstname.lastname@example.org> wrote:
> > I think we should accept the patch (modulo, of course, any fixes
> > required in the ordinary course of review), unless someone sees a
> > better, and relatively easy, way to provide the same benefit. ?We can
> > always rip it out if there turns out to be a better way.
> I'd like to see compile-time numbers. And I am not convinced
> (after looking at the testcase) that this transformation is valid
> unless you can prove that the narrower IVs do not wrap.
> Nathan, can you convince me that you are properly checking
> if the transformation is valid?
The function analyze_loop_index_definition_pattern aims to do exactly
that. The idea is that if we have:
for (index = start; index < end; index += incr)
If INDEX is not modified elsewhere in the loop, INDEX and END are of the
same type, and INCR is 1, then we know overflow does not occur. This
assumes INDEX is signed: I see after looking at
analyze_loop_index_definition_pattern that it has comments about the
safety of the transformation if INDEX is unsigned, but it never checks
for TYPE_UNSIGNED. Those checks might have gotten lost in the
conversion to tuples; I will need to fix that.