From patchwork Wed Jun 16 15:54:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 55902 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 978BFB7D61 for ; Thu, 17 Jun 2010 01:54:37 +1000 (EST) Received: (qmail 16951 invoked by alias); 16 Jun 2010 15:54:36 -0000 Received: (qmail 16937 invoked by uid 22791); 16 Jun 2010 15:54:35 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Jun 2010 15:54:31 +0000 Received: (qmail 19441 invoked from network); 16 Jun 2010 15:54:28 -0000 Received: from unknown (HELO ?172.16.1.24?) (maxim@127.0.0.2) by mail.codesourcery.com with ESMTPA; 16 Jun 2010 15:54:28 -0000 Message-ID: <4C18F3B2.8080708@codesourcery.com> Date: Wed, 16 Jun 2010 19:54:26 +0400 From: Maxim Kuvyrkov User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Jeff Law , gcc-patches Subject: 0002-Allow-constant-MEMs-through-calls.patch References: <4C18F225.2040509@codesourcery.com> In-Reply-To: <4C18F225.2040509@codesourcery.com> 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 The function gcse.c: compute_transpout() is responsible for filtering out expressions that do not survive function calls. Certain kinds of memory references, e.g., references to read-only memory can safely be propagated through calls. This patch improves compute_transpout() to allow that. OK to apply? Thank you, diff --git a/gcc/gcse.c b/gcc/gcse.c index 1dbd2f0..00f3841 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -4083,6 +4083,12 @@ compute_transpout (void) && CONSTANT_POOL_ADDRESS_P (XEXP (expr->expr, 0))) continue; + /* Handle constant memory references, e.g., PIC addresses. + We don't need to assume MEM_NOTRAP_P here because we only + care about MEM's value surviving the call. */ + if (MEM_READONLY_P (expr->expr) && !MEM_VOLATILE_P (expr->expr)) + continue; + /* ??? Optimally, we would use interprocedural alias analysis to determine if this mem is actually killed by this call. */