From patchwork Fri Aug 9 00:15:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 265866 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C4EFD2C00A8 for ; Fri, 9 Aug 2013 10:16:15 +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 :content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; q=dns; s=default; b=sRkqI5OZvcXEx5hfh bgJ5hQO+lavYJLymUu95lfzqit9kffihVKSiHxuWgqOmQqyG3R1xuBAcAUBNNI4G sOPN5Om6t5znPSNnvQS2atK1wuO8y4az/rTSFfoPWD7/6rzCjcor4E3CPZC+UJ8d vx/F70xq5Sm7wCjbA23yB8OP7k= 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 :content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; s=default; bh=KdBmDcNte9lroEjtu9+h1JL X4u0=; b=GhnputJ/kMkuEPrqFjdYzTT3ZdurE/SXOdSX7Lra67XlqDyN0Rlcod9 mc2/xGYyjWdOcxwBDkYX4QGRuHSuHKDYR9UFry3SEF8ktrc/V4dKEoa+2YAGRohC iYVxtZMlUEJpuXyqr6vqed9N2WV1M3Hq71oHVKw9fx0PmqM69Wr0= Received: (qmail 7068 invoked by alias); 9 Aug 2013 00:16:08 -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 7044 invoked by uid 89); 9 Aug 2013 00:16:07 -0000 X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=BAYES_50, FREEMAIL_FROM, KHOP_THREADED, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RDNS_NONE, SPF_PASS autolearn=no version=3.3.1 Received: from Unknown (HELO qmta02.emeryville.ca.mail.comcast.net) (76.96.30.24) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 09 Aug 2013 00:16:07 +0000 Received: from omta24.emeryville.ca.mail.comcast.net ([76.96.30.92]) by qmta02.emeryville.ca.mail.comcast.net with comcast id APuq1m0021zF43QA2QFzjj; Fri, 09 Aug 2013 00:15:59 +0000 Received: from [IPv6:2601:9:80:2ff:96:13a0:9db:cbee] ([IPv6:2601:9:80:2ff:96:13a0:9db:cbee]) by omta24.emeryville.ca.mail.comcast.net with comcast id AQFz1m00D00Dybl8kQFzCx; Fri, 09 Aug 2013 00:15:59 +0000 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: [PATCH] Fix expansion issues on type changing MEM_REFs on LHS (PR middle-end/48335) From: Mike Stump In-Reply-To: <20110330160546.GP18914@tyan-ft48-01.lab.bos.redhat.com> Date: Thu, 8 Aug 2013 17:15:59 -0700 Cc: gcc-patches@gcc.gnu.org Message-Id: <31B3A889-7A2A-49B0-B0D9-45624C4212DC@comcast.net> References: <20110330160546.GP18914@tyan-ft48-01.lab.bos.redhat.com> To: Jakub Jelinek X-Virus-Found: No On Mar 30, 2011, at 9:05 AM, Jakub Jelinek wrote: > + else if (bitpos >= mode_bitsize / 2) > + result = store_field (XEXP (to_rtx, 1), bitsize, > + bitpos - mode_bitsize / 2, mode1, from, > + TREE_TYPE (tem), get_alias_set (to), > + nontemporal); > - gcc_assert (bitpos == 0 || bitpos == GET_MODE_BITSIZE (mode1)); > - result = store_expr (from, XEXP (to_rtx, bitpos != 0), false, > - nontemporal); > + rtx temp = assign_stack_temp (GET_MODE (to_rtx), > + GET_MODE_SIZE (GET_MODE (to_rtx)), > + 0); > + write_complex_part (temp, XEXP (to_rtx, 0), false); > + write_complex_part (temp, XEXP (to_rtx, 1), true); > + result = store_field (temp, bitsize, bitpos, mode1, from, > + TREE_TYPE (tem), get_alias_set (to), > + nontemporal); > + emit_move_insn (XEXP (to_rtx, 0), read_complex_part (temp, false)); > + emit_move_insn (XEXP (to_rtx, 1), read_complex_part (temp, true)); I think this is bad. I think this patch fixes it. The problem is that we can't write outside the bounds of the object. So, instead we punt out of the register case, and instead spill it to memory that _is_ big enough, and then spill it back to registers. Of course, I'd rather emit a diagnostic when extra is non-zero… but not sure people yet buy into that around here. Thoughts? diff --git a/gcc/expr.c b/gcc/expr.c index 923f59b..f5744b0 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4815,7 +4815,8 @@ expand_assignment (tree to, tree from, bool nontemporal) bitregion_start, bitregion_end, mode1, from, get_alias_set (to), nontemporal); - else if (bitpos >= mode_bitsize / 2) + else if (bitpos >= mode_bitsize / 2 + && bitpos+bitsize <= mode_bitsize) result = store_field (XEXP (to_rtx, 1), bitsize, bitpos - mode_bitsize / 2, bitregion_start, bitregion_end, @@ -4834,8 +4835,12 @@ expand_assignment (tree to, tree from, bool nontemporal) } else { + HOST_WIDE_INT extra = 0; + if (bitpos+bitsize > mode_bitsize) + extra = bitpos+bitsize - mode_bitsize; rtx temp = assign_stack_temp (GET_MODE (to_rtx), - GET_MODE_SIZE (GET_MODE (to_rtx))); + GET_MODE_SIZE (GET_MODE (to_rtx)) + + extra); write_complex_part (temp, XEXP (to_rtx, 0), false); write_complex_part (temp, XEXP (to_rtx, 1), true); result = store_field (temp, bitsize, bitpos,