From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25035 invoked by alias); 1 Aug 2012 12:42:44 -0000 Received: (qmail 24979 invoked by uid 22791); 1 Aug 2012 12:42:43 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Aug 2012 12:42:30 +0000 Received: by yhjj56 with SMTP id j56so7259170yhj.20 for ; Wed, 01 Aug 2012 05:42:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.0.164 with SMTP id 4mr28646836oef.4.1343824949365; Wed, 01 Aug 2012 05:42:29 -0700 (PDT) Received: by 10.76.90.71 with HTTP; Wed, 1 Aug 2012 05:42:29 -0700 (PDT) In-Reply-To: <500AB52F.4050108@mentor.com> References: <500AB52F.4050108@mentor.com> Date: Wed, 01 Aug 2012 12:42:00 -0000 Message-ID: Subject: Re: [PATCH] propagate anti-range to switch in tree-vrp From: Richard Guenther To: Tom de Vries Cc: Jakub Jelinek , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg00019.txt.bz2 On Sat, Jul 21, 2012 at 3:57 PM, Tom de Vries 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 > > * 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.