From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17496 invoked by alias); 21 Aug 2005 13:52:42 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 17481 invoked by uid 22791); 21 Aug 2005 13:52:36 -0000 Received: from mtagate4.de.ibm.com (HELO mtagate4.de.ibm.com) (195.212.29.153) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 21 Aug 2005 13:52:36 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.12.10/8.12.10) with ESMTP id j7LDqYO0165434 for ; Sun, 21 Aug 2005 13:52:34 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id j7LDqXKF127256 for ; Sun, 21 Aug 2005 15:52:33 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11/8.13.3) with ESMTP id j7LDqXtD026515 for ; Sun, 21 Aug 2005 15:52:33 +0200 Received: from d12ml102.megacenter.de.ibm.com (d12ml102.megacenter.de.ibm.com [9.149.166.138]) by d12av02.megacenter.de.ibm.com (8.12.11/8.12.11) with ESMTP id j7LDqXhk026512; Sun, 21 Aug 2005 15:52:33 +0200 To: gcc@gcc.gnu.org Cc: Steven Bosscher , Roger Sayle , Paolo Bonzini , Mircea Namolaru MIME-Version: 1.0 Subject: Question about merging two instructions. From: Leehod Baruch Message-ID: Date: Sun, 21 Aug 2005 13:52:00 -0000 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2005-08/txt/msg00563.txt.bz2 Hello, I'm working on a the sign extension elimination pass. (see http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01087.html for details) I would like to merge these two instructions: (insn 1 0 2 0 (set (reg/v:Xmode r) (sign_extend:Xmode (op:Ymode (...)))) (insn 2 1 3 0 (set (lhs) (rhs))) where: 1. Xmode > Ymode 2. rhs and/or lhs may contain: (subreg:Ymode (reg/v:Xmode r) lowpart) The extension may be redundant here. I would like to merge these instructions and eliminate the extension, if possible. I tried to use simplify_replace_rtx to replace any use of (reg r) with the right-hand-side of the extension and simplify the result. But, it didn't work till I added this change: Index: simplify-rtx.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/simplify-rtx.c,v retrieving revision 1.243 diff -c -3 -p -r1.243 simplify-rtx.c *** simplify-rtx.c 16 Aug 2005 02:01:27 -0000 1.243 --- simplify-rtx.c 21 Aug 2005 12:07:57 -0000 *************** simplify_replace_rtx (rtx x, rtx old_rtx *** 319,325 **** return simplify_gen_ternary (code, mode, op_mode, op0, op1, op2); case RTX_EXTRA: - /* The only case we try to handle is a SUBREG. */ if (code == SUBREG) { op0 = simplify_replace_rtx (SUBREG_REG (x), old_rtx, new_rtx); --- 319,324 ---- *************** simplify_replace_rtx (rtx x, rtx old_rtx *** 329,334 **** --- 328,341 ---- GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x)); return op0 ? op0 : x; + } + if (code == SET) + { + op0 = simplify_replace_rtx (XEXP (x, 0), old_rtx, new_rtx); + op1 = simplify_replace_rtx (XEXP (x, 1), old_rtx, new_rtx); + if ((op0 == XEXP (x, 0)) && (op1 == XEXP (x, 1))) + return x; + return gen_rtx_SET (VOIDmode, op0, op1); } break; This way, when the replacement succeeds and the result instruction is recognizable, I can eliminate the extension. Does it seem like a good change? Does anyone have a better solution? Thanks, Leehod.