From patchwork Wed Jun 11 16:11:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 358774 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 D9682140078 for ; Thu, 12 Jun 2014 02:11:51 +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:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=gAJyMipFeKLMW92gX Qr20ipwOT8/GXRmIkSetDY8yVxsAHeQuXII+4D3A/KuhyysO+jEJQ+neFB2TGM4I CP6W9ggSwkQ3RyxMb47qjR8nroW7uOzH1djeCJntfX3lPFfEr42cGfObvzpUn+Ms awTBBNN9EiPOWcekkJEG3+gKeE= 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:references:mime-version :content-type:in-reply-to; s=default; bh=4EMWR9N2gLWachAUNtvPKYM uqIA=; b=LGt9rZkJk9Iv16Jw9WYddNkrvp8HwaXnLm4akSJqLH+KOWKJgneF8NM Tgu2LyxQ5qvcnBRTbNQvlDdpNArWnn7JF8ix4Nb27Tr80AUxB2owNcgAQ8STIuM9 /ZI3kbAiFwBO8q/2nx/nN5Zw6bqdItUJXfsUx5xB7QVgH/YnRMVo= Received: (qmail 17034 invoked by alias); 11 Jun 2014 16:11:45 -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 17024 invoked by uid 89); 11 Jun 2014 16:11:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 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-f176.google.com Received: from mail-pd0-f176.google.com (HELO mail-pd0-f176.google.com) (209.85.192.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Jun 2014 16:11:43 +0000 Received: by mail-pd0-f176.google.com with SMTP id p10so7390484pdj.21 for ; Wed, 11 Jun 2014 09:11:41 -0700 (PDT) X-Received: by 10.68.131.227 with SMTP id op3mr6332886pbb.87.1402503101736; Wed, 11 Jun 2014 09:11:41 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.40]) by mx.google.com with ESMTPSA id gq3sm9270603pbb.52.2014.06.11.09.11.39 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jun 2014 09:11:41 -0700 (PDT) Date: Wed, 11 Jun 2014 20:11:35 +0400 From: Ilya Enkovich To: Uros Bizjak Cc: Dominique Dhumieres , "gcc-patches@gcc.gnu.org" , Jeff Law Subject: Re: [PATCH, PR61446] Fix mode for register copy in REE pass Message-ID: <20140611161135.GK17894@msticlxl57.ims.intel.com> References: <20140610134545.67DC4105@mailhost.lps.ens.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 11 Jun 14:59, Uros Bizjak wrote: > On Tue, Jun 10, 2014 at 3:45 PM, Dominique Dhumieres wrote: > >> This patch fixes PR61446. ... > > > > Confirmed, it also allows to bootstrap Core* targets. > > Could it be reviewed and committed ASAP? > > > 2014-06-09 Ilya Enkovich > > > > PR 61446 > > * ree.c (find_and_remove_re): Narrow mode for register copy > > if required. > > Please also add the testcase form the PR. > > (I am not RTL reviewer, so I can't approve the patch). > > Uros. Hi, rgis one is the same but with testcase added. Bootstrapped and tested on linux-x86_64. Thanks, Ilya --- gcc/ 2014-06-11 Ilya Enkovich PR 61446 * ree.c (find_and_remove_re): Narrow mode for register copy if required. gcc/testsuite/ 2014-06-11 Ilya Enkovich * gcc.target/i386/pr61446.c : New. 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); } diff --git a/gcc/testsuite/gcc.target/i386/pr61446.c b/gcc/testsuite/gcc.target/i386/pr61446.c new file mode 100644 index 0000000..8537cdb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr61446.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/61446 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -m32 -march=corei7" } */ + +unsigned long long +foo (float a) +{ + const double dfa = a; + const unsigned int hi = dfa / 0x1p32f; + const unsigned int lo = dfa - (double) hi * 0x1p32f; + + return ((unsigned long long) hi << (4 * (8))) | lo; +}