From patchwork Thu Jan 3 08:23:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 209193 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 367B62C0080 for ; Thu, 3 Jan 2013 19:23:53 +1100 (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=1357806234; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=dvX8lZ/MH5e1a7g5RQ9n 1VQUC+U=; b=tWUXeseNuZaUgB5V46DHX6kRbhI/6/HOaDOvAh3RrTZ5Y1YuFUk9 OdL5Bmpn9JLXmj8YOdsAJseuXfG1qmuc7UfZhiu+NgW7MA0sV3/cbiyZKd33JH80 TEJ97+qQT84s6FEk+HJo1t2VsPcct50dAgT7WzcjrnPARuEfQphXfLU= 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:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FBDmeD4dkTsYR5asSInxyxp3XFj+XcTDbCCcUq94SC6n5Q4c61uNw7vlIzWND0 5Bn0vuyWoHXa0PcArafoWUpb3nvsWzosb6sVOTfxnuV2AUu3WANJpyvwwTddE3UC JIfjQlh5MFuXRoM6GPhQthV36Bs6k9AgosJKnJI7KSGQw=; Received: (qmail 13132 invoked by alias); 3 Jan 2013 08:23:45 -0000 Received: (qmail 13110 invoked by uid 22791); 3 Jan 2013 08:23:44 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, 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; Thu, 03 Jan 2013 08:23:39 +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 r038Ncir026140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Jan 2013 03:23:38 -0500 Received: from zalov.redhat.com (vpn1-4-31.ams2.redhat.com [10.36.4.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r038Na8u003880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Jan 2013 03:23:37 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id r038NZ0O008495; Thu, 3 Jan 2013 09:23:35 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r038NZkp008494; Thu, 3 Jan 2013 09:23:35 +0100 Date: Thu, 3 Jan 2013 09:23:35 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix vector ABS_EXPR >= 0 folding (PR tree-optimization/55832) Message-ID: <20130103082334.GE7269@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline 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 Hi! While omit_one_operand_loc fold_converts the value to the right type, when type is vector, it is not possible to convert that way integer_one_node. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-01-03 Jakub Jelinek Marc Glisse PR tree-optimization/55832 * fold-const.c (fold_binary_loc): For ABS_EXPR >= 0 and ABS_EXPR < 0 folding use constant_boolean_node instead of integer_{one,zero}_node. * gcc.c-torture/compile/pr55832.c: New test. Jakub --- gcc/fold-const.c.jj 2012-12-06 15:35:35.000000000 +0100 +++ gcc/fold-const.c 2013-01-02 09:48:42.906797768 +0100 @@ -13519,7 +13519,9 @@ fold_binary_loc (location_t loc, "when simplifying comparison of " "absolute value and zero"), WARN_STRICT_OVERFLOW_CONDITIONAL); - return omit_one_operand_loc (loc, type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, + constant_boolean_node (true, type), + arg0); } /* Convert ABS_EXPR < 0 to false. */ @@ -13533,7 +13535,9 @@ fold_binary_loc (location_t loc, "when simplifying comparison of " "absolute value and zero"), WARN_STRICT_OVERFLOW_CONDITIONAL); - return omit_one_operand_loc (loc, type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, + constant_boolean_node (false, type), + arg0); } /* If X is unsigned, convert X < (1 << Y) into X >> Y == 0 --- gcc/testsuite/gcc.c-torture/compile/pr55832.c.jj 2013-01-02 10:00:53.271626853 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr55832.c 2013-01-02 10:00:44.000000000 +0100 @@ -0,0 +1,23 @@ +/* PR tree-optimization/55832 */ + +int g, b; + +void +foo (void) +{ + union U { int i; unsigned short s; } a = { 0 }; + unsigned char c; + unsigned short d = 0, *p = &a.s; + + if (g) + a.i--; + + if (b && a.i < (d = 1)) + return; + + for (; a.i < 15; a.i++) + b |= d <= c; + + if (!*p) + g = 0; +}