This is the mail archive of the 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_EXPR lowering


> On Sun, Oct 26, 2003 at 12:19:55AM +0200, Zdenek Dvorak wrote:
> > The switch exprs are lowered into the form in that switch body is
> > composed just of regularly alternating CASE_LABEL_EXPRs and GOTO_EXPRs.
> > This whole is considered a single statement representing a multiway
> > jump.  Statement annotations attached to CASE_LABEL_EXPRs are (miss)used
> > to map the cases to edges via case_edge field.
> I think this is the wrong approach.  
> SWITCH_EXPRs already have a vector of all associated case labels, as
> seen in SWITCH_LABELS.  This is even collected during gimplification,
> so you don't have to do it yourself during lowering.
> In its lowered form, SWITCH_BODY becomes NULL.  We simply drop its
> container-ness and treat it as a multi-way branch.
> We replace all c=CASE_LABEL_EXPR with LABEL_EXPR<CASE_LABEL(c)>, so
> we no longer have CASE_LABEL_EXPRs in the instruction stream.  They
> continue to exist in the SWITCH_LABELS vector so that we have the
> mapping from input index to label.  Simplifying SWITCH_EXPRs when we
> propagate in constants is a simple matter of replacing the insn with
> a GOTO_EXPR to the correct labe.  Redirecting edges during jump 
> threading is a simple matter of replacing the CASE_LABEL of the 
> appropriate SWITCH_LABELS entry.
> There's likely some small amount of work needed in the tree->rtl 
> expander, but I wouldn't expect it to be much.

what advantage does this exactly have? I have no objections against
this or any other scheme, but it seems largely equivalent with my
approach (except that it is less consistent with the way how COND_EXPRs
are handled).  If we want to break this consistency, would not it be
better to rather implement some representation that will make the
manipulation with switch_exprs easier?


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