foreach ... else statement

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jan 6 22:32:29 PST 2009


Walter Bright wrote:
> grauzone wrote:
>> bearophile wrote:
>>> Don:
>>>> Actually Walter loves goto, so DMD copes really well with it.
>>>
>>> When possible it's better to use structured programming and avoid 
>>> gotos. That construct can avoid gotos in some common situations.
>>> And regarding the compiler back-end, I think it's also better to 
>>> start thinking what's good for LDC :-)
>>
>> I don't know how relevant this is, but: LLVM uses SSA for registers, 
>> and it seems to be simpler to convert code to SSA if there are no gotos:
>>
>> "We show that it is possible to generate SSA form in a single pass 
>> (even during parsing) if the program contains only structured control 
>> flow (i.e., no gotos). For such programs the dominator tree can be 
>> built on the fly, too."
>>
>> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.45.4503
> 
> I don't know what they're talking about. The D optimizer has no trouble 
> whatsoever building dominator graphs, no matter what rat's nest of gotos 
> are used. This technology was well understood in 1980.
> 
> In fact, the front end deconstructs *everything* into gotos, and that's 
> all the optimizer works with.

The challenge the paper addresses is constructing the SSA form in one 
shot. There are indeed algorithms that build the SSA in several passes.

My vague recollection from a compiler construction class is that there 
are a number of static analyses that need to do a fixed-point 
computation on loops. Such analyses can deal with any jumps except a 
particular one: jump forward from the outside of a loop in the middle of 
it. Does anyone know what analyses were those?


Andrei



More information about the Digitalmars-d mailing list