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] Switch stmts and inserting on edges


On Fri, 2003-05-30 at 11:23, Andrew MacLeod wrote:

> Any other suggestions? I havent thought of anything I actually like....
> 
The problem is that SWITCH_EXPRs still have implicit semantics that are
getting in the way.  I think this ought to be fixed by finishing Jason's
patch to expose SWITCH_EXPRs as explicit multi-way branches, or even
decision trees.

We already have all the switch() labels in SWITCH_LABELS(), but don't
seem to be using it for much.  What I have in mind is change this:

---------------------------------------------------------------------------------
  # BLOCK 0 (a.c:3).  PRED: -1.  SUCC: 3 2 1 4.
  switch (i_2)
    {
        # BLOCK 1 (a.c:5).  PRED: 0.  SUCC: 4.
        case 1:;
        i_3 = i_2 - 1;
        goto <UL14d0>;;
        
        # BLOCK 2 (a.c:9).  PRED: 0.  SUCC: 4.
        case 2:;
        i_4 = i_2 + 1;
        goto <UL14d0>;;
        
        # BLOCK 3 (a.c:13).  PRED: 0.  SUCC: 4.
        case 3:;
        default :;
        i_5 = i_2 + 3;
        goto <UL14d0>;
      }
    };
  
  # BLOCK 4.  PRED: 3 2 1 0.  SUCC: -2.
  <UL14d0>:;;
---------------------------------------------------------------------------------

into

---------------------------------------------------------------------------------
  # BLOCK 0 (a.c:3).  PRED: -1.  SUCC: 3 2 1 4.
  mbr (i_2, <1,case1>, <2,case2>, <3,case3>, <default>)
    {
        # BLOCK 1 (a.c:5).  PRED: 0.  SUCC: 4.
        case1:;
        i_3 = i_2 - 1;
        goto <UL14d0>;;
        
        # BLOCK 2 (a.c:9).  PRED: 0.  SUCC: 4.
        case2:;
        i_4 = i_2 + 1;
        goto <UL14d0>;;
        
        # BLOCK 3 (a.c:13).  PRED: 0.  SUCC: 4.
        case3:
        default :;
        i_5 = i_2 + 3;
        goto <UL14d0>;
      }
    };
  
  # BLOCK 4.  PRED: 3 2 1 0.  SUCC: -2.
  <UL14d0>:;;
---------------------------------------------------------------------------------

So, now if we want to split block #3, we just do:

---------------------------------------------------------------------------------
        # BLOCK 3 (a.c:13).  PRED: 0.  SUCC: 4.
        case3:
	goto default;

	# BLOCK 4 (a.c:13).  PRED: 0.  SUCC: 5.
	new_label:
	new_stmt;

        default :;
        i_5 = i_2 + 3;
        goto <UL14d0>;
---------------------------------------------------------------------------------

And rename the appropriate entry in SWITCH_LABELS() to have 'new_label'
be the last element.

Jason, how difficult would that change be?  I'm not proposing we do
decision trees right off the bat.  We may want to keep these multi way
branches until we have a pass to determine how dense the cases are.

In the meantime we could also do a quick hack to get around this
problem.  If that's the case, it doesn't matter how ugly it is as long
as it's easy to rip out when we finish fixing the representation of
SWITCH_EXPRs.


Diego.


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