From patchwork Sun Jun 9 08:57:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 250013 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id CBC2A2C02A8 for ; Sun, 9 Jun 2013 18:57:43 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=P04Vqs+ZkX6qlhaTujuS0nPtXhxAS Gs80HlpWbQ9ga6DuTwIC0yLGkUTC4ApXv7afaWOViH6bvJwgAJsIu9i5irABLypI pmfrp7YB2gkXspvCQ1IMe7OrqcNcZRqjhwo61JBhjpzTnu+QYiFa/6t6YIYFv8hq mUCfHiS6xZfSA4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=6BaA9/yw627LAeMtMim9822Jf9I=; b=C3r W835uR+5RG1x9yfirMWZpIexXjxP0Hh0KvbhGbZz7bMWsONgE/u4eG9DhOcf4Jwt 1U00PqTGRj4vppMpLcCQCUWCDQCpmvpCci+/DJmQ7BkBh59w6LQVU7wKJjTPmLRA Xw4IrrCaO6XHYiG3XN8Zl8jjTSqFUm6+HB7vfkio= Received: (qmail 32257 invoked by alias); 9 Jun 2013 08:57:38 -0000 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 Received: (qmail 32218 invoked by uid 89); 9 Jun 2013 08:57:33 -0000 X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 09 Jun 2013 08:57:32 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r598vVx0005568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 9 Jun 2013 04:57:31 -0400 Received: from zalov.cz (vpn-54-65.rdu2.redhat.com [10.10.54.65]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r598vTvR032273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 9 Jun 2013 04:57:30 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r598vRHt001708; Sun, 9 Jun 2013 10:57:28 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r598vQRl001707; Sun, 9 Jun 2013 10:57:26 +0200 Date: Sun, 9 Jun 2013 10:57:24 +0200 From: Jakub Jelinek To: Uros Bizjak , Richard Henderson Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix TARGET_READ_MODIFY_WRITE peephole2s (PR target/57568) Message-ID: <20130609085724.GM1493@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! These two peephole2s misbehave if it sees e.g. regN = mem regN = regN + regN mem = regN CC = regN != 0 because transforming it into mem = mem + regN ; CC = mem != 0 is wrong, I forgot to verify the second operand of the plusminuslogic_operator doesn't overlap the first operand. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8 and perhaps also 4.7 (where it is just latent)? 2013-06-09 Jakub Jelinek PR target/57568 * config/i386/i386.md (TARGET_READ_MODIFY_WRITE peepholes): Ensure that operands[2] doesn't overlap with operands[0]. * gcc.c-torture/execute/pr57568.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2013-06-03 19:15:34.000000000 +0200 +++ gcc/config/i386/i386.md 2013-06-08 21:59:43.416954936 +0200 @@ -16591,6 +16591,7 @@ (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]) + && !reg_overlap_mentioned_p (operands[0], operands[2]) && (mode != QImode || immediate_operand (operands[2], QImode) || q_regs_operand (operands[2], QImode)) @@ -16655,6 +16656,7 @@ (define_peephole2 || immediate_operand (operands[2], SImode) || q_regs_operand (operands[2], SImode)) && !reg_overlap_mentioned_p (operands[0], operands[1]) + && !reg_overlap_mentioned_p (operands[0], operands[2]) && ix86_match_ccmode (peep2_next_insn (3), (GET_CODE (operands[3]) == PLUS || GET_CODE (operands[3]) == MINUS) --- gcc/testsuite/gcc.c-torture/execute/pr57568.c.jj 2013-06-08 22:03:38.861005658 +0200 +++ gcc/testsuite/gcc.c-torture/execute/pr57568.c 2013-06-08 22:03:19.000000000 +0200 @@ -0,0 +1,12 @@ +/* PR target/57568 */ + +extern void abort (void); +int a[6][9] = { }, b = 1, *c = &a[3][5]; + +int +main () +{ + if (b && (*c = *c + *c)) + abort (); + return 0; +}