From patchwork Wed Apr 25 09:21:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 154844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 13D1FB6FA3 for ; Wed, 25 Apr 2012 19:22:15 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1335950536; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=kAr+Ovl4Z2brorZ8a9k/DSeziX8=; b=ckqt5pm2U+SQ1Ti +ZkGrcooLR366UCPozz2EDVGxfx33EzXIq421Aqb2QFM5g+Ql70SmYUpoqp/ihfL q90SiCNvjHJ6ZbTGUD2yOKeBntxnO5RhHkRN70bPpWmC6b8clJJk6J5aE6lq5WE8 hvgiA4KTnpkrAdgkvby6G6Y0DqfA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=BR9/pxxL5Yn0PB6H5WqdONW2YTGIiqu0mH/vK5GO5mPgbTZcT84VUkdV7tCkt8 NYgn48nkCdmMn6yPC5j9U1drtMxrZL1BwdPN1rRfYbKLyoPsz0ap97qp2oyZmezO BvyFGvSKAl/P++RxPDutnYK0+NvPWnFGwSnKrBIHjuqmE=; Received: (qmail 16746 invoked by alias); 25 Apr 2012 09:22:09 -0000 Received: (qmail 16736 invoked by uid 22791); 25 Apr 2012 09:22:07 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Apr 2012 09:21:49 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3P9Lnl6030464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Apr 2012 05:21:49 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3P9LmDH026637 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 25 Apr 2012 05:21:49 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id q3P9LlQ2013849; Wed, 25 Apr 2012 11:21:48 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id q3P9LlRH013847; Wed, 25 Apr 2012 11:21:47 +0200 Date: Wed, 25 Apr 2012 11:21:47 +0200 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix VRP ICE on x >> cst1; if (x cmp cst2) (PR tree-optimization/53058, take 2) Message-ID: <20120425092147.GT16117@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20120423230106.GN16117@tyan-ft48-01.lab.bos.redhat.com> <20120424071014.GQ16117@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Tue, Apr 24, 2012 at 10:33:58AM +0200, Richard Guenther wrote: > > So like this instead? > > Yes! Unfortunately that didn't bootstrap, apparently double-int.h is included in gen* which aren't linked with double-int.o, and the inlines stay at -O0 or with -fkeep-inline-functions. Even guarding with #ifndef GENERATOR_FILE doesn't work, because gengtype is apparently built both with that and without. So this new version instead just prototypes them in double-int.h and defines in double-int.c. Still ok? 2012-04-25 Jakub Jelinek PR tree-optimization/53058 * double-int.h (double_int_max_value, double_int_min_value): New prototypes. * double-int.c (double_int_max_value, double_int_min_value): New functions. * tree-vrp.c (register_edge_assert_for_2): Compare mask for LE_EXPR or GT_EXPR with double_int_max_value instead of double_int_mask. * gcc.c-torture/compile/pr53058.c: New test. Jakub --- gcc/double-int.h.jj 2012-03-29 12:01:31.623648408 +0200 +++ gcc/double-int.h 2012-04-24 17:54:37.798945484 +0200 @@ -1,5 +1,5 @@ /* Operations with long integers. - Copyright (C) 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2008, 2010, 2012 Free Software Foundation, Inc. This file is part of GCC. @@ -242,6 +242,9 @@ double_int double_int_sext (double_int, double_int double_int_zext (double_int, unsigned); double_int double_int_mask (unsigned); +double_int double_int_max_value (unsigned int, bool); +double_int double_int_min_value (unsigned int, bool); + #define ALL_ONES (~((unsigned HOST_WIDE_INT) 0)) /* The operands of the following comparison functions must be processed --- gcc/double-int.c.jj 2012-04-02 21:40:10.000000000 +0200 +++ gcc/double-int.c 2012-04-24 17:55:44.745723956 +0200 @@ -1,5 +1,5 @@ /* Operations with long integers. - Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2009, 2010, 2012 Free Software Foundation, Inc. This file is part of GCC. @@ -616,6 +616,26 @@ double_int_mask (unsigned prec) return mask; } +/* Returns a maximum value for signed or unsigned integer + of precision PREC. */ + +double_int +double_int_max_value (unsigned int prec, bool uns) +{ + return double_int_mask (prec - (uns ? 0 : 1)); +} + +/* Returns a minimum value for signed or unsigned integer + of precision PREC. */ + +double_int +double_int_min_value (unsigned int prec, bool uns) +{ + if (uns) + return double_int_zero; + return double_int_lshift (double_int_one, prec - 1, prec, false); +} + /* Clears the bits of CST over the precision PREC. If UNS is false, the bits outside of the precision are set to the sign bit (i.e., the PREC-th one), otherwise they are set to zero. --- gcc/tree-vrp.c.jj 2012-04-24 07:59:58.142773712 +0200 +++ gcc/tree-vrp.c 2012-04-24 17:41:10.473562899 +0200 @@ -4565,6 +4565,7 @@ register_edge_assert_for_2 (tree name, e && INTEGRAL_TYPE_P (TREE_TYPE (name2)) && IN_RANGE (tree_low_cst (cst2, 1), 1, prec - 1) && prec <= 2 * HOST_BITS_PER_WIDE_INT + && prec == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (val))) && live_on_edge (e, name2) && !has_single_use (name2)) { @@ -4598,8 +4599,10 @@ register_edge_assert_for_2 (tree name, e new_val = val2; else { + double_int maxval + = double_int_max_value (prec, TYPE_UNSIGNED (TREE_TYPE (val))); mask = double_int_ior (tree_to_double_int (val2), mask); - if (double_int_minus_one_p (double_int_sext (mask, prec))) + if (double_int_equal_p (mask, maxval)) new_val = NULL_TREE; else new_val = double_int_to_tree (TREE_TYPE (val2), mask); --- gcc/testsuite/gcc.c-torture/compile/pr53058.c.jj 2012-04-24 17:41:10.475662886 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr53058.c 2012-04-24 17:41:10.475662886 +0200 @@ -0,0 +1,12 @@ +/* PR tree-optimization/53058 */ + +int a, b, c; + +void +foo () +{ + c = b >> 16; + if (c > 32767) + c = 0; + a = b; +}