This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add if-chain to switch conversion pass.
- From: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Jakub Jelinek <jakub at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>, Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- Date: Thu, 14 Nov 2019 13:30:54 +0100
- Subject: Re: [PATCH] Add if-chain to switch conversion pass.
- References: <2c3db526-cac6-4eeb-4afb-12024f8d5af2@suse.cz> <20191104144851.GJ4650@tucnak> <CAFiYyc0j3uYK9Z5LVtcoG0r9PhXB=Pj5kTy6vU0XzV7H=edO2A@mail.gmail.com> <20191106220256.4e7c63a6@nbbrfq.loc> <bf5af985-054b-3cc4-ac68-bf0ee5fec269@suse.cz>
On Thu, 14 Nov 2019 10:41:25 +0100
Martin Liška <mliska@suse.cz> wrote:
> On 11/6/19 10:02 PM, Bernhard Reutner-Fischer wrote:
> > Also why do you punt on duplicate conditions like in
> >
> >> +++ b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-4.c
> >> +int main(int argc, char **argv)
> >> +{
> >> + if (argc == 1)
> >> + else if (argc == 2)
> >> + else if (argc == 3)
> >> + else if (argc == 4)
> >> + else if (argc == 1)
> >> + {
> > This block is dead, isn't it. Why don't you just discard it but punt?
> >
>
> Hello.
>
> After I moved the pass later in optimization pipeline, such dead conditions
nice
> are already gone. What's remaining are situations like:
>
> if (argc >= 1 && argc <= 10)
> ...
> else if (argc >= 8 && argc <= 15)
>
> which are overlapping intervals. I'm not planning to handle these in the first
> iteration of the patch.
yea. Later when we see a new interval overlapping old, we can adjust
the new to clamp to the intersection of old and new. We'd need to
generate one or more artificial intervals covering the delta interval
with the body of new if we find intervening previous intervals, which
complicates things more than a first attempt of a patch should
supposedly do, agree. One step at a time :)
thanks for moving it later in the pipeline!
cheers,