From patchwork Wed May 30 05:24:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 161855 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 B7BC1B6FD4 for ; Wed, 30 May 2012 15:25:14 +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=1338960318; 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=DM/2TBhNF3TWaNoXoHoN AI373Xk=; b=bMBM3RoxHvMW4QN76YLvNwlHSZ0n6Klw/9xnBKwsX0KUZOstk6fw NPW7Ikuip500wNHqr3nL/BWMoloQ4Xx/v65MZ4sXJzOLzN7XltGkXBpz2DFkLeWd InFgPgHjpiS7+qgMGToMXkS1KFlto0vtrjmAXaZiipLR6sUmzx7FD1w= 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=daKa8/oEcCwU3mQZIaLJHijuCh1fK3LCbkY5FDOTC9D/F/tkPIb9Ayrh6j4dIj dkaGlum4FTsJB5Vz97UCsSG19mvzZ3RahXGuq2ybxgaV7AwmTCbTVdkJg6LHwxoB l5fE0D/zBKVpa4n3Rt8AWYAfrFDMeiGFptUH4UbAY4jbY=; Received: (qmail 10249 invoked by alias); 30 May 2012 05:25:07 -0000 Received: (qmail 10224 invoked by uid 22791); 30 May 2012 05:25:04 -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, 30 May 2012 05:24:46 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4U5OkF0019349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 May 2012 01:24:46 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q4U5OjL6004319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 30 May 2012 01:24:46 -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 q4U5Oi0A005917 for ; Wed, 30 May 2012 07:24:45 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id q4U5OiC2005915 for gcc-patches@gcc.gnu.org; Wed, 30 May 2012 07:24:44 +0200 Date: Wed, 30 May 2012 07:24:44 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix combiner to create canonical CONST_INTs (PR rtl-optimization/53519) Message-ID: <20120530052444.GJ16117@tyan-ft48-01.lab.bos.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! GEN_INT (GET_MODE_MASK (mode)) isn't canonical CONST_INT for mode, because it is zero extended rather than sign-extended for GET_MODE_BITSIZE (mode) < HOST_BITS_PER_WIDE_INT modes. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-05-30 Jakub Jelinek PR rtl-optimization/53519 * combine.c (simplify_shift_const_1) : Use constm1_rtx instead of GEN_INT (GET_MODE_MASK (mode)) as second operand of XOR. * gcc.c-torture/compile/pr53519.c: New test. Jakub --- gcc/combine.c.jj 2012-05-12 10:21:06.000000000 +0200 +++ gcc/combine.c 2012-05-29 21:53:23.448801930 +0200 @@ -10284,8 +10284,7 @@ simplify_shift_const_1 (enum rtx_code co break; /* Make this fit the case below. */ - varop = gen_rtx_XOR (mode, XEXP (varop, 0), - GEN_INT (GET_MODE_MASK (mode))); + varop = gen_rtx_XOR (mode, XEXP (varop, 0), constm1_rtx); continue; case IOR: --- gcc/testsuite/gcc.c-torture/compile/pr53519.c.jj 2012-05-29 22:02:16.593763702 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr53519.c 2012-05-29 22:01:10.000000000 +0200 @@ -0,0 +1,26 @@ +/* PR rtl-optimization/53519 */ + +int a, b, c, d, e; + +short int +foo (short int x) +{ + return a == 0 ? x : 0; +} + +short int +bar (int x, int y) +{ + return x + y; +} + +void +baz (void) +{ + if (!e) + { + int f = foo (65535 ^ b); + if (bar (!6L <= ~f, ~e) == c) + d = 0; + } +}