From patchwork Tue May 15 11:47:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 159299 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 614F9B6F62 for ; Tue, 15 May 2012 21:47:40 +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=1337687261; 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=iNxO777pP8Nr2zKuVJ/b iqnfe8g=; b=uapm3Us+9d36T+hYWO8jwsfk6m0WmG9vR6XEp9/baV2zj/+5YWLk E+eNQ6udxudLyrU4lG5yiqDIIAxAbPWJ/YqVjL+e0c1rcEuspQ4DdWVy5S83kaJf T15yYY9RRmJP4nhKlZ5B/L+WvM6y7TfZBsFeae7ch5TDmZEVNJrJQ70= 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=fiRLXSxQUWYMyQdZeIGXnV5TQyzFJ4Jh7CYCrJeCCNMz8HKzMowEb/v405NpGx JRKzyl2knSOcpGxLvrCvTZ+5qXAEOCee7KwN2HtjMJGkAomO1mp5mysdl0AINI5e r2nj0KbllRRZ1CygfXo1/FEJAaVsKB9z+XnuvteLSWsMQ=; Received: (qmail 30714 invoked by alias); 15 May 2012 11:47:34 -0000 Received: (qmail 30702 invoked by uid 22791); 15 May 2012 11:47:32 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_DD, TW_DQ, 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; Tue, 15 May 2012 11:47:16 +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 q4FBlFSg030406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 May 2012 07:47:16 -0400 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 q4FBlFbs029124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 15 May 2012 07:47:15 -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 q4FBlEfg023304; Tue, 15 May 2012 13:47:14 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id q4FBlDXY023303; Tue, 15 May 2012 13:47:13 +0200 Date: Tue, 15 May 2012 13:47:13 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Another fix for TARGET_READ_MODIFY_WRITE i386 peepholes (PR target/53358) Message-ID: <20120515114713.GK16117@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 is a similar problem as PR52086, but back then when looking at whether other peepholes might need similar treatment I didn't think about the possibility that addqi_1 pattern would allow non-q constraint register. Apparently it does in some of the alternatives, the insn is then emitted widened as addl etc., but for addqi_2 it isn't possible (it adds to memory). Fixed thusly, bootstrapped/regtested on i686-linux, ok for trunk/4.7? 2012-05-15 Jakub Jelinek PR target/53358 * config/i386/i386.md (*addqi_2 peephole with QImode addition): Check that operands[2] is either immediate, or q_regs_operand. * gcc.dg/pr53358.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2012-05-02 09:42:33.000000000 +0200 +++ gcc/config/i386/i386.md 2012-05-15 10:48:19.197020618 +0200 @@ -17209,6 +17209,9 @@ (define_peephole2 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ()) && peep2_reg_dead_p (4, operands[0]) && !reg_overlap_mentioned_p (operands[0], operands[1]) + && (mode != QImode + || immediate_operand (operands[2], QImode) + || q_regs_operand (operands[2], QImode)) && ix86_match_ccmode (peep2_next_insn (3), (GET_CODE (operands[3]) == PLUS || GET_CODE (operands[3]) == MINUS) --- gcc/testsuite/gcc.dg/pr53358.c.jj 2012-05-15 11:54:40.680128157 +0200 +++ gcc/testsuite/gcc.dg/pr53358.c 2012-05-15 11:54:47.698086318 +0200 @@ -0,0 +1,22 @@ +/* PR target/53358 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ +/* { dg-additional-options "-mtune=pentium4" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +struct S { unsigned char s, t[17]; }; +int bar (void); + +void +foo (struct S *x) +{ + unsigned char i, z; + if (bar ()) + { + z = bar (); + bar (); + x->s += z; + for (i = 0; i < x->s; i++) + x->t[i] = bar (); + } +}