This is the mail archive of the
mailing list for the GCC project.
Re: [tree-ssa] SWITCH_EXPR lowering
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Richard Henderson <rth at redhat dot com>,Andrew MacLeod <amacleod at redhat dot com>,gcc-patches <gcc-patches at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>,Diego Novillo <dnovillo at redhat dot com>, jh at suse dot cz
- Date: Sat, 1 Nov 2003 15:13:41 +0100
- Subject: Re: [tree-ssa] SWITCH_EXPR lowering
- References: <1067015195.14404.3043.camel@p4> <20031024173314.GA17702@atrey.karlin.mff.cuni.cz> <1067017615.14175.3094.camel@p4> <20031024175758.GB17291@atrey.karlin.mff.cuni.cz> <1067030697.14175.3476.camel@p4> <20031024213156.GA22864@atrey.karlin.mff.cuni.cz> <1067032171.21257.3504.camel@p4> <1067032627.14404.3520.camel@p4> <20031025221955.GA16508@atrey.karlin.mff.cuni.cz> <20031026080601.GA31855@redhat.com>
> 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?