From patchwork Sun Aug 26 19:20:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 180081 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 70E842C00F6 for ; Mon, 27 Aug 2012 05:20:58 +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=1346613658; 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=dZgKuxqSeeIIZnU1uSsPb0QY6q4=; b=NmIxwLqd841KIZJ 3AVMfaq3dre0vSIvlZVC2ifgfWBrvHFk2C7lyw6i+jyNKqmKanSKMbTxmOU24N/w 8QtubY84PN6LGvHVReuHHDo6kup+GBxuH2JpPXGJhHtPUtba4jWyoME4SI2LGu5A 6sOwFes1QwAV1yaJyUtVJ5OL56Dw= 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=TSGixBR5AC2iBpR3QbsQm4UKhSnN+eGhMPvNwUxkILyGBFpeBMevUhwklisPHP nWPbqZr6kOe5p1I2VZQ8DlbMuMhwvQFxZUyEX1zxaYQxkBz7PWcUy2csF71bRJTg jWLmGmLcNG8tHjyfGHImigbki7lxFpIziPdrAmw0doOT0=; Received: (qmail 25196 invoked by alias); 26 Aug 2012 19:20:54 -0000 Received: (qmail 25188 invoked by uid 22791); 26 Aug 2012 19:20:54 -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-wg0-f47.google.com (HELO mail-wg0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 26 Aug 2012 19:20:41 +0000 Received: by wgbfa7 with SMTP id fa7so2148060wgb.16 for ; Sun, 26 Aug 2012 12:20:40 -0700 (PDT) Received: by 10.180.103.136 with SMTP id fw8mr19906785wib.20.1346008840333; Sun, 26 Aug 2012 12:20:40 -0700 (PDT) Received: from localhost ([2.26.188.227]) by mx.google.com with ESMTPS id n15sm267818wie.7.2012.08.26.12.20.39 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 26 Aug 2012 12:20:39 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [MIPS, committed] Tweak r10k cache barrier code Date: Sun, 26 Aug 2012 20:20:40 +0100 Message-ID: <87harp31fb.fsf@talisman.home> 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 r10k_safe_mem_expr_p couldn't cope with a MEM_REF of an ADDR_EXPR, which for some reason is produced for r10k-cache-barrier-8.c when compiled with -O2 -lto but not when compiled with just -O2. This function is still much too conservative, but I wanted to be safe for kernel code that plays clever tricks with link-time symbol definitions. A trivial example is: extern char _region_start[]; where _region_start is defined in the linker script. _region_start[1] can't be seen as an in-range access to an object as far as the -mr10k-cache-barrier= option is concerned. Tested on mipsisa64-elf, mips64-elf and mips64-linux-gnu. Applied. Will be tested once gcc.target/mips uses gcc-dg. Richard gcc/ * config/mips/mips.c (r10k_safe_mem_expr_p): Use get_inner_reference. Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2012-08-26 11:35:15.000000000 +0100 +++ gcc/config/mips/mips.c 2012-08-26 11:36:43.667807911 +0100 @@ -14446,17 +14446,18 @@ r10k_safe_address_p (rtx x, rtx insn) static bool r10k_safe_mem_expr_p (tree expr, HOST_WIDE_INT offset) { - if (offset < 0 || offset >= int_size_in_bytes (TREE_TYPE (expr))) - return false; + HOST_WIDE_INT bitoffset, bitsize; + tree inner, var_offset; + enum machine_mode mode; + int unsigned_p, volatile_p; - while (TREE_CODE (expr) == COMPONENT_REF) - { - expr = TREE_OPERAND (expr, 0); - if (expr == NULL_TREE) - return false; - } + inner = get_inner_reference (expr, &bitsize, &bitoffset, &var_offset, &mode, + &unsigned_p, &volatile_p, false); + if (!DECL_P (inner) || !DECL_SIZE_UNIT (inner) || var_offset) + return false; - return DECL_P (expr); + offset += bitoffset / BITS_PER_UNIT; + return offset >= 0 && offset < tree_low_cst (DECL_SIZE_UNIT (inner), 1); } /* A for_each_rtx callback for which DATA points to the instruction