From patchwork Mon Mar 25 07:15:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Cheng X-Patchwork-Id: 230575 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 764752C00AE for ; Mon, 25 Mar 2013 18:16:19 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=wINb7gWBKFEAbzcm3AOGd02v+6juHv2fzkHcVpZz5b10yQM32WDSk 8Kbq4N6J6Dg0s2ZU7Lcw/zuSfxQBknhn/oTAGXj5GH5ZsYOLbOclpyHrLbDP+Uol ZyLN7MAQIBXH/xb95rqayfPBt1UToRsuf4KXj3yb4RdsT7/QqMi2Mo= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=jsK5wzK366Uz30UtEys7+cQQTTA=; b=PoW+ScCzal5ZhxuVSMKO VY86WXh0PUQsNx8onIlWdlFe0ZFv5diJh5V83lLWVYTg3NGsIRzpsEjusjkn8zOR r6vm6SBK61ScBvdb/+FaQ+TQWCh+SoaiJKCh75k0MWXecxjypjNDSg4ORIvLPTnG HAwMwMZHZfLMGvDe7tCuH6M= Received: (qmail 13385 invoked by alias); 25 Mar 2013 07:16:08 -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 13346 invoked by uid 89); 25 Mar 2013 07:16:00 -0000 X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_50, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 25 Mar 2013 07:15:58 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 25 Mar 2013 07:15:55 +0000 Received: from Binsh02 ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Mon, 25 Mar 2013 07:15:54 +0000 From: "Bin Cheng" To: Subject: FW: [PATCH GCC/pr56124] Don't prefer memory if the source of load operation has side effect Date: Mon, 25 Mar 2013 15:15:09 +0800 Message-ID: <000901ce2928$7d570a50$78051ef0$@cheng@arm.com> MIME-Version: 1.0 X-MC-Unique: 113032507155501601 X-Virus-Found: No Sorry for the wrong list. -----Original Message----- From: Bin Cheng [mailto:bin.cheng@arm.com] Sent: Monday, March 25, 2013 3:00 PM To: gcc@gcc.gnu.org Subject: [PATCH GCC/pr56124] Don't prefer memory if the source of load operation has side effect Hi, As reported in PR56124, IRA causes redundant reload by preferring to put pseudo which is target of loading in memory. Generally this is good but the case in which the src of loading has side effect. This patch fixes this issue by checking whether source of loading has side effect. I tested the patch on x86/thumb2. Is it OK? Thanks. 2013-03-25 Bin Cheng PR target/56124 * ira-costs.c (scan_one_insn): Check whether the source rtx of loading has side effect. Index: gcc/ira-costs.c =================================================================== --- gcc/ira-costs.c (revision 197029) +++ gcc/ira-costs.c (working copy) @@ -1293,10 +1293,13 @@ scan_one_insn (rtx insn) a memory requiring special instructions to load it, decreasing mem_cost might result in it being loaded using the specialized instruction into a register, then stored into stack and loaded - again from the stack. See PR52208. */ + again from the stack. See PR52208. + + Don't do this if SET_SRC (set) has side effect. See PR56124. */ if (set != 0 && REG_P (SET_DEST (set)) && MEM_P (SET_SRC (set)) && (note = find_reg_note (insn, REG_EQUIV, NULL_RTX)) != NULL_RTX - && ((MEM_P (XEXP (note, 0))) + && ((MEM_P (XEXP (note, 0)) + && !side_effects_p (SET_SRC (set))) || (CONSTANT_P (XEXP (note, 0)) && targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)), XEXP (note, 0))