From patchwork Tue Jun 10 07:42:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 357761 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E28E6140087 for ; Tue, 10 Jun 2014 17:42:42 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=X5/01KHxZ57Kh2iVrmDVqSM5JES4mLEyNE2X6SpxR1FVQ0wRmWnfS 1jRYCYYtgIVU06Nxg3nuxFy3rPzoQpYxjzTUl+smRXCAbTz8x041JQEGUfLHISZN XNxIX4xMYnSANUWdXSWro3l7JvM1xP9pYmDISUAeWFobQdZhQuPN/c= 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:subject:message-id:mime-version:content-type; s= default; bh=05MS6Vy58nd2G2VQNyXoojiMR7c=; b=mTVLRoYZWRusGVfhA4AM 3Pbs673MH7ZnjqrIA9OGleBwtWpJ4yBosUGDy+/Fba9d6jwrAZn2Vv1dGhjgWm6G VPYY1mNK10ivPs1eGJdnUIYcLyTQ7adFVVu38yeNUyaVKdkHR9a7xlPu2JKVehPk qGEF9cyb/Yp6SWM2erTWbMw= Received: (qmail 2965 invoked by alias); 10 Jun 2014 07:42:36 -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 2955 invoked by uid 89); 10 Jun 2014 07:42:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f175.google.com Received: from mail-pd0-f175.google.com (HELO mail-pd0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 10 Jun 2014 07:42:34 +0000 Received: by mail-pd0-f175.google.com with SMTP id z10so5828077pdj.34 for ; Tue, 10 Jun 2014 00:42:32 -0700 (PDT) X-Received: by 10.68.216.101 with SMTP id op5mr9080654pbc.148.1402386152711; Tue, 10 Jun 2014 00:42:32 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.55.41]) by mx.google.com with ESMTPSA id zb2sm67859016pbb.45.2014.06.10.00.42.31 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jun 2014 00:42:32 -0700 (PDT) Date: Tue, 10 Jun 2014 11:42:22 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR61446] Fix mode for register copy in REE pass Message-ID: <20140609145256.GA10949@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, This patch fixes PR61446. The problem appears when we insert value copies after transformations. We use the widest extension mode met in a chain, but it may be wider than original destination register size. This patch checks it and use smaller mode if required. Bootstrapped and tested on linux-x86_64. Does it look OK? Thanks, Ilya --- 2014-06-09 Ilya Enkovich PR 61446 * ree.c (find_and_remove_re): Narrow mode for register copy if required. diff --git a/gcc/ChangeLog.pr61446 b/gcc/ChangeLog.pr61446 new file mode 100644 index 0000000..b9e2148 --- /dev/null +++ b/gcc/ChangeLog.pr61446 @@ -0,0 +1,5 @@ +2014-06-09 Ilya Enkovich + + PR 61446 + * ree.c (find_and_remove_re): Narrow mode for register copy + if required. diff --git a/gcc/ree.c b/gcc/ree.c index ade413e..6d34764 100644 --- a/gcc/ree.c +++ b/gcc/ree.c @@ -1088,14 +1088,24 @@ find_and_remove_re (void) /* Use the mode of the destination of the defining insn for the mode of the copy. This is necessary if the defining insn was used to eliminate a second extension - that was wider than the first. */ + that was wider than the first. Truncate mode if it is + too wide for destination reg. */ rtx sub_rtx = *get_sub_rtx (def_insn); rtx pat = PATTERN (curr_insn); - rtx new_dst = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)), - REGNO (XEXP (SET_SRC (pat), 0))); - rtx new_src = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)), - REGNO (SET_DEST (pat))); - rtx set = gen_rtx_SET (VOIDmode, new_dst, new_src); + unsigned int regno = REGNO (XEXP (SET_SRC (pat), 0)); + enum machine_mode mode = GET_MODE (SET_DEST (sub_rtx)); + rtx new_dst, new_src, set; + + if (HARD_REGNO_NREGS (regno, mode) != 1) + { + mode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (mode)); + while (HARD_REGNO_NREGS (regno, GET_MODE_WIDER_MODE (mode)) == 1) + mode = GET_MODE_WIDER_MODE (mode); + } + + new_dst = gen_rtx_REG (mode, REGNO (XEXP (SET_SRC (pat), 0))); + new_src = gen_rtx_REG (mode, REGNO (SET_DEST (pat))); + set = gen_rtx_SET (VOIDmode, new_dst, new_src); emit_insn_after (set, def_insn); }