This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] RFC: Making control flow more explicit



On Thursday, August 7, 2003, at 2:45 PM, Jason Merrill wrote:


I think that the WHIRL example is relevant here.

VHWHIRL is very close to the source, with arbitrary nesting of constructs.
This corresponds to GENERIC. Inlining is done at this level in both their
compiler and ours (except that all the frontends currently lower straight
to GIMPLE, but that's another issue).


HWHIRL breaks apart nested expressions (calls, comma ops), but still
retains control flow structures. This corresponds to (current) GIMPLE.
Apparently the SGI compiler does IPA, LNO (huh?) and "the PREOPT part of
the global scalar optimizer" at this level.


MWHIRL lowers all control flow to gotos, possibly conditional or computed.
This seems to be what you're looking for. We probably want to define a
lower GIMPLE to match, and do the lowering somewhere in the middle of
optimization.



Actually, it appears they perform goto removal in the preopt phase. "// goto conversion if (WOPT_Enable_Goto && (phase == PREOPT_LNO_PHASE || phase == PREOPT_PHASE)) { SET_OPT_PHASE("Goto conversion"); OPT_POOL_Push( &Opt_local_pool, MEM_DUMP_FLAG+2 ); { GOTO_TABLE goto_table( wn_tree, &Opt_local_pool ); goto_table.Remove_Gotos(); // goto_table gets destructed before we pop the pool } "

Where they really mean goto removal:

"// Convert gotos into WHILEs and IFs. This is loosely based on
// the paper "Taming Control Flow: A Structured Approach to Eliminating
// Goto Statements" by Ana Erosa and Laurie Hendren. As a first cut,
// and probably as a last cut, we limit ourselves to removing sibling
// gotos and gotos going out of an 'IF'.
// Our requirements are different than Erosa's. We don't need
// to get rid of every goto. For most of the other gotos, although
// not all, we don't benefit by getting rid of them. Limiting ourselves
// simplifies the algorithm and prevents bloat (Granted Erosa claims the
// bloat is small).
//
// Additional limitations. We limit the number of gotos out of IFs that we
// remove to MAX_GOTO_EXPANDING_TRANSFORMATIONS = 20. This prevents code
// bloat in the bad cases. We don't touch gotos to "break" labels. These
// transformations unnecessarily mess up case statements.
// We don't create IFs out of unconditional gotos. The optimizer promises to
// erase these gotos.
//
// WHIRL doesn't allow gotos into structured control flow. Goto
// conversion creates such gotos. So TCF also dismantles such control
// flow nodes (whether or not TCF created them)"
"


Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]