user-guided speculative precomputation? (my wacky ia64 idea)

James Morrison ja2morri@csclub.uwaterloo.ca
Wed Apr 7 05:19:00 GMT 2004


Daniel Jacobowitz <drow@false.org> writes:
> > > {
> > > 	n = NodeArray[0];
> > > 	while(n && remaining)
> > > 	{
> > > 		doSomeWork();
> > > #pragma delinquent_load
> > > 		n->i = n->next->j + n->next->k + n->next->l;
                         ^^^^^^^^ next = 0 => segfault.
> > > 		n = n->next;
> > > 		remaining--;
> > > 	}
> > > }
> > > 
> > 
> >  I'm not sure if I should be scared by this example or put it up to lazyness.
> > However, n is going to be compared each time we go through the loop even
> > though it is only supposed to be tested once.  If n is ever 0 at the top of
> > the loop, after executing the loop, then a segfault would have already occured.
> > I don't suppose it's possible to optimize this, is it?
> 
> Eh, you're incorrect.  Note the n = n->next at the bottom of the loop.
> 
> In general, if the circumstance you're describing had actually occured
> in this example - yes, I believe that at least tree-ssa or lno could
> optimize this.  There would be a non-null marker on the dereferenced
> pointer, which would reach a PHI at the top of the loop.
> 
> -- 
> Daniel Jacobowitz
> MontaVista Software                         Debian GNU/Linux Developer

 Note the line above that.  However, the lno branch from 20040321 doesn't
take the if (n == 0) out of the bottom of the loop.  I think it is valid to
have a signal handler catch a segfault which then sets n to null.

Jim



More information about the Gcc mailing list