From patchwork Mon Jun 18 09:18:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 165424 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 8314FB72D1 for ; Mon, 18 Jun 2012 19:18:24 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340615905; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Mail-Followup-To:Subject:Date:Message-ID: User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=WGkNvZMUiLizYY/su4FSpHI6THU=; b=vQt7Y/iPn0MfwkY b4SGwa18fZhRfCSLLBgVr3jXOn2dGyiYU36BPchZvvonKCxkQ5cLa3jTfd3CdG4F IP2ee9S4hRJn+bBajidWaw5GqLVsYBEwZ0s5/pvDoS+0TttdrieONZR/Rc8P5Eo9 i4503PMdEf6cpKrLPs/nvBnVl1Jw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Mail-Followup-To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MlaIY8ul8pJnvAdw205UhUO8D7NRMmi4ZrlpmZknj28EW/dQjJW+vSgyf1BMIK qC8JiCYPRJtH+9QDFgBM/tHsiEoPYR96QnhJd0xsdeCC9ol2/dvERJu/Rt98xFca g6bJqOyKIYK0s/ASQImdUw97JiY1WOM6FmM6aMN2RkkRQ=; Received: (qmail 8176 invoked by alias); 18 Jun 2012 09:18:20 -0000 Received: (qmail 8161 invoked by uid 22791); 18 Jun 2012 09:18:19 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-bk0-f47.google.com (HELO mail-bk0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Jun 2012 09:18:06 +0000 Received: by bkcjm2 with SMTP id jm2so4175936bkc.20 for ; Mon, 18 Jun 2012 02:18:05 -0700 (PDT) Received: by 10.204.154.18 with SMTP id m18mr6386288bkw.23.1340011084771; Mon, 18 Jun 2012 02:18:04 -0700 (PDT) Received: from richards-thinkpad.stglab.manchester.uk.ibm.com (gbibp9ph1--blueice2n1.emea.ibm.com. [195.212.29.75]) by mx.google.com with ESMTPS id gw6sm17689054bkc.16.2012.06.18.02.18.01 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 02:18:03 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: PR 53698: missing address conversion in expand_expr_addr_expr_1 Date: Mon, 18 Jun 2012 10:18:00 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 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 The result of expand_expr_addr_expr_1 is eventually converted to tmode, and any variable offset is likewise applied in tmode, so tmode also seems like the natural mode for applying constant offsets. This patch makes sure that the operand is converted to tmode first, just like we do for variable offsets. It fixes a case where the new plus_constant assert triggers. Tested on x86_64-linux-gnu. Also tested by HJ on x32 (thanks). OK to install? Richard gcc/ PR middle-end/53698 * expr.c (expand_expr_addr_expr_1): Convert to tmode before performing an addition. gcc/testsuite/ PR middle-end/53698 * gcc.target/i386/pr53698.c: New test. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2012-06-06 10:09:21.000000000 +0100 +++ gcc/expr.c 2012-06-18 09:35:35.361926943 +0100 @@ -7631,6 +7631,7 @@ expand_expr_addr_expr_1 (tree exp, rtx t of such an object. */ gcc_assert ((bitpos % BITS_PER_UNIT) == 0); + result = convert_memory_address_addr_space (tmode, result, as); result = plus_constant (tmode, result, bitpos / BITS_PER_UNIT); if (modifier < EXPAND_SUM) result = force_operand (result, target); Index: gcc/testsuite/gcc.target/i386/pr53698.c =================================================================== --- /dev/null 2012-05-16 15:38:36.131804707 +0100 +++ gcc/testsuite/gcc.target/i386/pr53698.c 2012-06-18 09:36:01.033855874 +0100 @@ -0,0 +1,16 @@ +/* { dg-do compile { target { ! { ia32 } } } } */ +/* { dg-options "-O -mx32 -maddress-mode=long -fno-tree-dominator-opts" } */ + +extern char foo[]; + +void +test2 (void) +{ + int s; + for (s = 0;; ++s) + { + if (foo[s] != s) + __builtin_abort (); + foo[s] = s; + } +}