From patchwork Thu Aug 2 10:17:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paulo J. Matos" X-Patchwork-Id: 174714 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 9DB1D2C0096 for ; Thu, 2 Aug 2012 20:18:15 +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=1344507495; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:To:From:Subject:Date:Lines:Message-ID:Mime-Version: Content-Type:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=4qB4UIlS2dUQEMmzdjc2k6Gmq1w=; b=K9CpfZacRWtBXxw yTFWNmQ4VYbAcxEY5tI7jSXvUqPZ1PALVctHGUSWTNiqnmYLa+B8E1Ph8qFmXYOS WNrdU2/rLsZLvgGdj1x2eIKm/mVKUB07CFaXX70X4WG6ilrj4XWPD12JVEbGVVSP 8FAROla9ZuFJLekh9oeBVAP0SA/U= 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:To:From:Subject:Date:Lines:Message-ID:Mime-Version:Content-Type:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=T8WPZ1WQtMtW9XYZBXevx2In4LujyP4hH5u6FP+un5jBfpPbvncLpBD1KwPkPi mH1Z+03M08RcpOSVd2zPpLpi5IYttb5HY6qlO2Hut8vrw1h2ejniuQrQRd7n1bZy HDBeTC7d2shhdYtUVmjBbGZg8QeR0T+SF8R88fcTt/f30=; Received: (qmail 20357 invoked by alias); 2 Aug 2012 10:18:10 -0000 Received: (qmail 20347 invoked by uid 22791); 2 Aug 2012 10:18:09 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_00, RCVD_NUMERIC_HELO, SPF_HELO_PASS, TW_EG, TW_GC, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Aug 2012 10:17:47 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SwsTP-0008QF-P0 for gcc-patches@gcc.gnu.org; Thu, 02 Aug 2012 12:17:43 +0200 Received: from 193.128.72.68 ([193.128.72.68]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Aug 2012 12:17:43 +0200 Received: from paulo by 193.128.72.68 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Aug 2012 12:17:43 +0200 To: gcc-patches@gcc.gnu.org From: "Paulo J. Matos" Subject: PATCH: Remove redundant instructions after regcprop Date: Thu, 02 Aug 2012 11:17:27 +0100 Lines: 90 Message-ID: Mime-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 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 Extended regcprop to check and remove for redundant move instructions resulting from the pass. Paulo. 2012-08-02 Paulo Matos * regcprop.c (copy_value): remove check for redundant moves. * regcprop.c (copy_value): add check for redundant moves, remove instructions if redundant. --- //depot/bc/main/devHost/gcc46/gcc/gcc/regcprop.c 2011-09-06 14:29:15.000000000 0100 +++ /home/pm18/p4ws/pm18_binutils/bc/main/devHost/gcc46/gcc/gcc/regcprop.c 2011-09-06 14:29:15.000000000 0100 @@ -301,11 +301,8 @@ unsigned int dn, sn; unsigned int i; - /* ??? At present, it's possible to see noop sets. It'd be nice if - this were cleaned up beforehand... */ - if (sr == dr) - return; - + gcc_assert(dr != sr); + /* Do not propagate copies to the stack pointer, as that can leave memory accesses with no scheduling dependency on the stack update. */ if (dr == STACK_POINTER_REGNUM) @@ -734,9 +731,9 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) { bool anything_changed = false; - rtx insn; + rtx insn, next; - for (insn = BB_HEAD (bb); ; insn = NEXT_INSN (insn)) + FOR_BB_INSNS_SAFE(bb, insn, next) { int n_ops, i, alt, predicated; bool is_asm, any_replacements; @@ -755,10 +752,7 @@ insn, vd); } - if (insn == BB_END (bb)) - break; - else - continue; + continue; } set = single_set (insn); @@ -966,10 +960,19 @@ /* Notice copies. */ if (set && REG_P (SET_DEST (set)) && REG_P (SET_SRC (set))) - copy_value (SET_DEST (set), SET_SRC (set), vd); - - if (insn == BB_END (bb)) - break; + { + unsigned int dr = REGNO(SET_DEST(set)); + unsigned int sr = REGNO(SET_SRC(set)); + + if(dr == sr) + { + /* noop set */ + delete_insn_and_edges(insn); + } + else + copy_value (SET_DEST (set), SET_SRC (set), vd); + } + } return anything_changed;