From patchwork Thu Feb 2 08:15:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 139090 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 BBB16B71A8 for ; Thu, 2 Feb 2012 19:15:56 +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=1328775358; 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=MctLVTLpRBYkLfXWrNYW 3Plxg44=; b=gAc0XCnZjzlDY7z/sdhiZCNLs87Evl3RH71sI5GS4qHYrXPFqOUD lphdSVMYLpXkjXFyWcFB7DJDh6gDV4sKC2/iX3cVwxMNKoJly4mvVx/nmkwceGLC i8uhfV8lMV4bakPg0Weq32Ud3QfbUgogdmux2xjWTEdPMY3vF61fOso= 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=PG0gvbdq1UoBKOwD9JYtgswKVOvB4/tJbxplwXY3JD91ma5da5FKrukyiZXSPR GLXALXpqhPsh6JbjLDWw+Lr0KGrMFrdtthBgZVbL3ItS2RLoJKpKvZieBmiV4vhD RMe6Ik6hgIW3jwyXOwvZXDvHSikX5qEytS/C0A611fZVk=; Received: (qmail 25258 invoked by alias); 2 Feb 2012 08:15:45 -0000 Received: (qmail 25238 invoked by uid 22791); 2 Feb 2012 08:15:40 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, 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, 02 Feb 2012 08:15:20 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q128FKPr016568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Feb 2012 03:15:20 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q128FIUl003957 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Feb 2012 03:15:19 -0500 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 q128FIMN025156; Thu, 2 Feb 2012 09:15:18 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id q128FHZ5025154; Thu, 2 Feb 2012 09:15:17 +0100 Date: Thu, 2 Feb 2012 09:15:17 +0100 From: Jakub Jelinek To: Uros Bizjak , Richard Henderson Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix i?86 mem += reg + comparison peephole (PR target/52086) Message-ID: <20120202081516.GX18768@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! This peephole, as shown on the testcase, happily transforms a QImode memory load into a register, followed by SImode addition of that reg and %ebp, followed by QImode store of that back into the same memory and QImode comparison of that with zero into a QImode addition of the register to the memory with setting flags instead of clobbering them. The problem with that is that for -m32 %ebp can't be used in QImode instructions. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-02-02 Jakub Jelinek PR target/52086 * config/i386/i386.md (*addqi_2 peephole with SImode addition): Check that operands[2] is either immediate, or q_regs_operand. * gcc.dg/pr52086.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2012-01-13 21:47:34.000000000 +0100 +++ gcc/config/i386/i386.md 2012-02-01 22:42:57.805296347 +0100 @@ -17232,6 +17232,9 @@ (define_peephole2 && REG_P (operands[0]) && REG_P (operands[4]) && REGNO (operands[0]) == REGNO (operands[4]) && peep2_reg_dead_p (4, operands[0]) + && (mode != QImode + || immediate_operand (operands[2], SImode) + || q_regs_operand (operands[2], SImode)) && !reg_overlap_mentioned_p (operands[0], operands[1]) && ix86_match_ccmode (peep2_next_insn (3), (GET_CODE (operands[3]) == PLUS --- gcc/testsuite/gcc.dg/pr52086.c.jj 2012-02-01 22:56:54.520519545 +0100 +++ gcc/testsuite/gcc.dg/pr52086.c 2012-02-01 22:56:35.000000000 +0100 @@ -0,0 +1,21 @@ +/* PR target/52086 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +struct S { char a; char b[100]; }; +int bar (void); +int baz (int); + +void +foo (struct S *x) +{ + if (bar () & 1) + { + char c = bar (); + baz (4); + x->a += c; + while (x->a) + x->b[c] = bar (); + } +}