[tree-ssa] COND_EXPR lowering.

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Fri Oct 24 17:43:00 GMT 2003


Hello,

>  >> > + 
>  >> > + 	  slow = e->dest;
>  >> > + 	  set_slow = 0;
>  >> > + 
>  >> > + 	  last = e->dest->succ;
>  >> > + 	  for (dest = e->dest->succ->dest;
>  >> > + 	       tree_forwarder_block_p (dest);
>  >> > + 	       last = dest->succ,
>  >> > + 	       dest = dest->succ->dest,
>  >> > + 	       set_slow ^= 1)
>  >> > + 	    {
>  >> > + 	      /* Infinite loop detected.  */
>  >> > + 	      if (slow == dest)
>  >> > + 		break;
>  >> > + 	      if (set_slow)
>  >> > + 		slow = slow->succ->dest;
>  >> > + 
>  >> > + 	      if (dest->succ->dest == EXIT_BLOCK_PTR)
>  >> > + 		break;
>  >> > + 	    }
>  >> > + 
>  >> > + 	  if (dest == e->dest)
>  >> > + 	    continue;
>  >> > + 	      
>  >> 
>  >> So if we do detect and infinite loop, we might still redirect the edges
>  >> anyway? Does that actually serve a purpose? It looks like we'd be
>  >> threading into an arbitary point in the cycle?
>  >
>  >Yes we are.  Neither feature nor bug, just it is easier not to handle it
>  >specially when it does not have to be.
> This was actually some of the code I really didn't like in Zdenek's
> threader.  It's far from obvious what that code is doing.   I really
> don't like the coding style for the "for" loop either.  This is naturally
> a recursive problem

huh? What is recursive on this problem???? It is just following a single
path in cfg.  I don't see a single reason to use a recursion for this.

> , so unless there's a performance issue, let's use
> recursion.
> 
> The way it detects loops is also far from obvious.  I think it's far
> more straightforward to note which blocks you've forwarded through and
> not revisit the same block more than once.  

OK, this can be done.

>  >> ie, we could see something like:
>  >> if (TREE_CODE (expr) == GOTO_EXPR
>  >>   follow_goto (expr)
>  >> else
>  >> if (TREE_CODE (expr) == COND_EXPR)
>  >>   {
>  >>     follow_goto (COND_EXPR_THEN (expr));
>  >>     follow_goto (COND_EXPR_ELSE (expr));
>  >>   }
>  >> where follow_goto wants to treat it just like a stmt, and may ask for
>  >> the BB...
>  >
>  >Why the hell should we do something that stupid? This is what cfg is
>  >here for.
> You can't always use the CFG for everything.

I don't say for everything.  But following the gotos is the reason for
having cfg.

Zdenek



More information about the Gcc-patches mailing list