From patchwork Fri Oct 28 05:10:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 122344 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 5CFF71007DB for ; Fri, 28 Oct 2011 16:11:20 +1100 (EST) Received: (qmail 30283 invoked by alias); 28 Oct 2011 05:11:14 -0000 Received: (qmail 30266 invoked by uid 22791); 28 Oct 2011 05:11:12 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from shards.monkeyblade.net (HELO shards.monkeyblade.net) (198.137.202.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Oct 2011 05:10:58 +0000 Received: from localhost (cpe-66-65-61-233.nyc.res.rr.com [66.65.61.233]) (authenticated bits=0) by shards.monkeyblade.net (8.14.4/8.14.4) with ESMTP id p9S5AuSX010485 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 27 Oct 2011 22:10:57 -0700 Date: Fri, 28 Oct 2011 01:10:56 -0400 (EDT) Message-Id: <20111028.011056.2300286905172357624.davem@davemloft.net> To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix illegal register substitutions on big-endian during cprop_reg. From: David Miller Mime-Version: 1.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 As discussed in the thread starting at: http://gcc.gnu.org/ml/gcc/2011-10/msg00478.html We need to make the tests done in copyprop_hardreg_forward_1() match those performed in copy_value(), and in particular make sure that if we are narrowing the mode on big-endian we do not perform the substitution. Committed to trunk. gcc/ * regcprop.c (copyprop_hardreg_forward_1): Reject the transformation when we narrow the mode on big endian. --- gcc/ChangeLog | 5 +++++ gcc/regcprop.c | 8 ++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 403fb60..54e059e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-10-27 David S. Miller + + * regcprop.c (copyprop_hardreg_forward_1): Reject the + transformation when we narrow the mode on big endian. + 2011-10-27 Jakub Jelinek * config/i386/sse.md (avx_cvtpd2dq256_2, avx_cvttpd2dq256_2, diff --git a/gcc/regcprop.c b/gcc/regcprop.c index ad92a64..b0f0343 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -824,6 +824,14 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) if (hard_regno_nregs[regno][mode] > hard_regno_nregs[regno][vd->e[regno].mode]) goto no_move_special_case; + + /* And likewise, if we are narrowing on big endian the transformation + is also invalid. */ + if (hard_regno_nregs[regno][mode] + < hard_regno_nregs[regno][vd->e[regno].mode] + && (GET_MODE_SIZE (vd->e[regno].mode) > UNITS_PER_WORD + ? WORDS_BIG_ENDIAN : BYTES_BIG_ENDIAN)) + goto no_move_special_case; } /* If the destination is also a register, try to find a source