From patchwork Wed Oct 10 06:39:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 190561 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 688072C0087 for ; Wed, 10 Oct 2012 17:39:40 +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=1350455980; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To: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=5Q6egk4xzJuLuVk6p/5y SmmqaFI=; b=BPvNK0+kCxvOCMOszIqhjUuUgrfr1f4UC1K4Jk5HBCc6Jc4M2Etb LEw7bM1S8XdUq4xSJ/WfNiaols9/IKk6C3XQmd9zcJN7suNWS3+tY9M4QEx8M+Jn +t2vAmWkzSj9X37tXXcPogzpeE7dLtKq4xl3Yh4mYhxgj1L4ir5cK1s= 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: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=LjbhLPXO1ZvG9gGiMtej1aPKdoPpJAAsGre+HR1juGAyfIKIwwHZPCtNoDxFNU ZQnE7CU+4ALM9cJyGzPUy1HYvw0iWdab2rdAYBtC0fDItSBNGXZM1pRMDfKTS/+5 +lZPaaQRut5tu6C948nxqxzTMl3uWs0BE3diRDEFwkaDI=; Received: (qmail 20660 invoked by alias); 10 Oct 2012 06:39:34 -0000 Received: (qmail 20551 invoked by uid 22791); 10 Oct 2012 06:39:32 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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, 10 Oct 2012 06:39:26 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9A6dP6I029086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Oct 2012 02:39:25 -0400 Received: from zalov.redhat.com (vpn1-7-201.ams2.redhat.com [10.36.7.201]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9A6dOSM010558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 10 Oct 2012 02:39:25 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q9A6dNM8018514 for ; Wed, 10 Oct 2012 08:39:23 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q9A6dN9k018513 for gcc-patches@gcc.gnu.org; Wed, 10 Oct 2012 08:39:23 +0200 Date: Wed, 10 Oct 2012 08:39:23 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix simplify_truncation (PR middle-end/54862) Message-ID: <20121010063923.GK26735@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! On 32-bit HWI warning there is a warning about signed (INTVAL) vs. unsigned ({,op_}precision) comparison (on 64-bit HWI that doesn't trigger, as INTVAL is 64-bit signed long, while precision is 32-bit unsigned). This patch fixes the warning and makes sure we don't try to optimize shifts by negative count. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-10-10 Jakub Jelinek PR middle-end/54862 * simplify-rtx.c (simplify_truncation): Compare UINTVAL instead of INTVAL of second argument with precision resp. op_precision. Jakub --- gcc/simplify-rtx.c.jj 2012-10-08 21:37:33.000000000 +0200 +++ gcc/simplify-rtx.c 2012-10-09 13:48:24.269969321 +0200 @@ -668,7 +668,7 @@ simplify_truncation (enum machine_mode m && CONST_INT_P (XEXP (op, 1)) && GET_CODE (XEXP (op, 0)) == SIGN_EXTEND && GET_MODE (XEXP (XEXP (op, 0), 0)) == mode - && INTVAL (XEXP (op, 1)) < precision) + && UINTVAL (XEXP (op, 1)) < precision) return simplify_gen_binary (ASHIFTRT, mode, XEXP (XEXP (op, 0), 0), XEXP (op, 1)); @@ -680,7 +680,7 @@ simplify_truncation (enum machine_mode m && CONST_INT_P (XEXP (op, 1)) && GET_CODE (XEXP (op, 0)) == ZERO_EXTEND && GET_MODE (XEXP (XEXP (op, 0), 0)) == mode - && INTVAL (XEXP (op, 1)) < precision) + && UINTVAL (XEXP (op, 1)) < precision) return simplify_gen_binary (LSHIFTRT, mode, XEXP (XEXP (op, 0), 0), XEXP (op, 1)); @@ -692,7 +692,7 @@ simplify_truncation (enum machine_mode m && (GET_CODE (XEXP (op, 0)) == ZERO_EXTEND || GET_CODE (XEXP (op, 0)) == SIGN_EXTEND) && GET_MODE (XEXP (XEXP (op, 0), 0)) == mode - && INTVAL (XEXP (op, 1)) < precision) + && UINTVAL (XEXP (op, 1)) < precision) return simplify_gen_binary (ASHIFT, mode, XEXP (XEXP (op, 0), 0), XEXP (op, 1)); @@ -705,8 +705,7 @@ simplify_truncation (enum machine_mode m && 2 * precision <= op_precision && CONST_INT_P (XEXP (op, 1)) && (INTVAL (XEXP (op, 1)) & (precision - 1)) == 0 - && INTVAL (XEXP (op, 1)) >= 0 - && INTVAL (XEXP (op, 1)) < op_precision) + && UINTVAL (XEXP (op, 1)) < op_precision) { int byte = subreg_lowpart_offset (mode, op_mode); int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT;