Thread overview
[dmd-internals] dmd commit, revision 821
Dec 27, 2010
dsource.org
Dec 27, 2010
Brad Roberts
Dec 27, 2010
Don Clugston
Dec 27, 2010
Brad Roberts
December 27, 2010
dmd commit, revision 821


user: walter

msg:
bugzilla 3681 ICE(go.c): when function takes too long to optimize, only with -O.

http://www.dsource.org/projects/dmd/changeset/821

paths changed:
U   branches/dmd-1.x/src/backend/cdef.h
U   branches/dmd-1.x/src/backend/el.c
U   branches/dmd-1.x/src/backend/el.h
U   branches/dmd-1.x/src/backend/go.c
U   trunk/src/backend/cdef.h
U   trunk/src/backend/el.c
U   trunk/src/backend/el.h
U   trunk/src/backend/go.c

December 27, 2010
Would this alternative be better (totally untested)?

// Each pass through the loop can reduce only one level of comma expression.
// The infinite loop check needs to take this into account.
int iterationLimit = 200;
for (b = startblock; b; b = b->Bnext)
{
    if (!b->Belem)
        continue;
    int d = el_countCommas(b->Belem);
    iterationLimit += d;
}

The justification being that each comma operator really ought to have a chance to be reduced, not just the first max number of commas in a single block.

On Mon, 27 Dec 2010, dsource.org wrote:

> Date: Mon, 27 Dec 2010 02:46:28 -0500
> From: dsource.org <noreply at dsource.org>
> Reply-To: Discuss the internals of DMD <dmd-internals at puremagic.com>
> To: dmd-internals at puremagic.com
> Subject: [dmd-internals] dmd commit, revision 821
> 
> dmd commit, revision 821
> 
> 
> user: walter
> 
> msg:
> bugzilla 3681 ICE(go.c): when function takes too long to optimize, only with -O.
> 
> http://www.dsource.org/projects/dmd/changeset/821
> 
> paths changed:
> U   branches/dmd-1.x/src/backend/cdef.h
> U   branches/dmd-1.x/src/backend/el.c
> U   branches/dmd-1.x/src/backend/el.h
> U   branches/dmd-1.x/src/backend/go.c
> U   trunk/src/backend/cdef.h
> U   trunk/src/backend/el.c
> U   trunk/src/backend/el.h
> U   trunk/src/backend/go.c
> 
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
> 
December 27, 2010
On 27 December 2010 09:01, Brad Roberts <braddr at puremagic.com> wrote:
> Would this alternative be better (totally untested)?
>
> // Each pass through the loop can reduce only one level of comma expression.
> // The infinite loop check needs to take this into account.
> int iterationLimit = 200;
> for (b = startblock; b; b = b->Bnext)
> {
> ? ?if (!b->Belem)
> ? ? ? ?continue;
> ? ?int d = el_countCommas(b->Belem);
> ? ?iterationLimit += d;
> }
>
> The justification being that each comma operator really ought to have a chance to be reduced, not just the first max number of commas in a single block.

No, it doesn't work like that. The optimizer drops one level of comma
expressions on _every_ expression tree in the block.
The number of iterations is determined by the maximum, not the total.
Also note that this commit does *not* affect the generated code in any
way, it's used only in an assert, to check for infinite loops in the
optimizer.

There is a further explanation in the patch I attached to the bug report.

>> bugzilla 3681 ICE(go.c): when function takes too long to optimize, only with -O.
December 27, 2010
Thanks for the explanation.  Makes sense and makes the bug fix make more sense too.

On Mon, 27 Dec 2010, Don Clugston wrote:
> 
> On 27 December 2010 09:01, Brad Roberts <braddr at puremagic.com> wrote:
> > Would this alternative be better (totally untested)?
> >
> > // Each pass through the loop can reduce only one level of comma expression.
> > // The infinite loop check needs to take this into account.
> > int iterationLimit = 200;
> > for (b = startblock; b; b = b->Bnext)
> > {
> > ? ?if (!b->Belem)
> > ? ? ? ?continue;
> > ? ?int d = el_countCommas(b->Belem);
> > ? ?iterationLimit += d;
> > }
> >
> > The justification being that each comma operator really ought to have a chance to be reduced, not just the first max number of commas in a single block.
> 
> No, it doesn't work like that. The optimizer drops one level of comma
> expressions on _every_ expression tree in the block.
> The number of iterations is determined by the maximum, not the total.
> Also note that this commit does *not* affect the generated code in any
> way, it's used only in an assert, to check for infinite loops in the
> optimizer.
> 
> There is a further explanation in the patch I attached to the bug report.
> 
> >> bugzilla 3681 ICE(go.c): when function takes too long to optimize, only with -O.
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>