This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] propagate anti-range to switch in tree-vrp
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 1 Aug 2012 14:42:29 +0200
- Subject: Re: [PATCH] propagate anti-range to switch in tree-vrp
- References: <500AB52F.4050108@mentor.com>
On Sat, Jul 21, 2012 at 3:57 PM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> Jakub,
>
> this patch adds propagation of anti-ranges to switches.
>
> The test-case is this:
> ...
> void
> f3 (int s)
> {
> if (s >> 3 == -2)
> /* s in range [ -16, -9]. */
> ;
> else
> {
> /* s in range ~[-16, -9], so none of the case labels can be taken. */
> switch (s)
> {
> case -16:
> case -12:
> case -9:
> link_error ();
> break;
> default:
> break;
> }
> }
> }
> ...
>
> The call to link_error is unreachable but tree-vrp fails to analyze that.
>
> Using the patch, the switch is replaced by the default case.
>
> Bootstrapped and reg-tested (Ada inclusive) on x86_64.
>
> OK for trunk?
Ok.
Thanks,
Richard.
> Thanks,
> - Tom
>
> 2012-07-21 Tom de Vries <tom@codesourcery.com>
>
> * tree-vrp.c (find_case_label_ranges): New function.
> (vrp_visit_switch_stmt, simplify_switch_using_ranges): Use
> find_case_label_ranges instead of find_case_label_range. Handle second
> range.
>
> * gcc.dg/tree-ssa/vrp72.c: New test.