From patchwork Thu Oct 21 14:26:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bingfeng Mei X-Patchwork-Id: 68610 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 ED8F1B6EF1 for ; Fri, 22 Oct 2010 01:26:42 +1100 (EST) Received: (qmail 12910 invoked by alias); 21 Oct 2010 14:26:37 -0000 Received: (qmail 12900 invoked by uid 22791); 21 Oct 2010 14:26:36 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_05, TW_LB, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mms2.broadcom.com (HELO mms2.broadcom.com) (216.31.210.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Oct 2010 14:26:31 +0000 Received: from [10.16.192.232] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Thu, 21 Oct 2010 07:26:23 -0700 X-Server-Uuid: D3C04415-6FA8-4F2C-93C1-920E106A2031 Received: from SJEXCHCCR02.corp.ad.broadcom.com ([10.16.192.130]) by SJEXCHHUB02.corp.ad.broadcom.com ([10.16.192.232]) with mapi; Thu, 21 Oct 2010 07:26:23 -0700 From: "Bingfeng Mei" To: "gcc-patches@gcc.gnu.org" cc: "Richard Guenther" , "zsojka@seznam.cz" , "eres@il.ibm.com" Date: Thu, 21 Oct 2010 07:26:10 -0700 Subject: [PATCH] PR45834: make restrict qualifier work for char pointer type. Message-ID: <7FB04A5C213E9943A72EE127DB74F0ADA691645C5F@SJEXCHCCR02.corp.ad.broadcom.com> x-cr-puzzleid: {12F25CAA-0EFA-45B1-9A26-4CDE575A67AA} x-cr-hashedpuzzle: F3vB IAmR IaAE JIzN LSBg LfW3 TIN7 TduB W1sX dJLo ihrI jDZr jQ8O kL59 nhwa o2pj; 4; ZQByAGUAcwBAAGkAbAAuAGkAYgBtAC4AYwBvAG0AOwBnAGMAYwAtAHAAYQB0AGMAaABlAHMAQABnAGMAYwAuAGcAbgB1AC4AbwByAGcAOwByAGkAYwBoAGEAcgBkAC4AZwB1AGUAbgB0AGgAZQByAEAAZwBtAGEAaQBsAC4AYwBvAG0AOwB6AHMAbwBqAGsAYQBAAHMAZQB6AG4AYQBtAC4AYwB6AA==; Sosha1_v1; 7; {12F25CAA-0EFA-45B1-9A26-4CDE575A67AA}; YgBtAGUAaQBAAGIAcgBvAGEAZABjAG8AbQAuAGMAbwBtAA==; Thu, 21 Oct 2010 14:26:10 GMT; WwBQAEEAVABDAEgAXQAgAFAAUgA0ADUAOAAzADQAOgAgAG0AYQBrAGUAIAByAGUAcwB0AHIAaQBjAHQAIABxAHUAYQBsAGkAZgBpAGUAcgAgAHcAbwByAGsAIABmAG8AcgAgAGMAaABhAHIAIABwAG8AaQBuAHQAZQByACAAdAB5AHAAZQAuAA== 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 Hi, This patch fixes bug PR45834. In alias.c, a check for QImode prevents later alias analysis based on restrict qualifier for char pointer type. This check is based on ancient code (at least 1997), and other modern way has been implemented for dealing that (MEM_ALIAS_SET == 0) according to Richard. Bootstrapped and tested for x86_64-unknown-linux-gnu. Before the patch powerpc-elf-gcc -O2 tst.c -S void foo (char * __restrict a, char *__restrict b, char * __restrict c) { *a = *b; *(a+1) = *c; } foo: lbz 0,0(4) stb 0,0(3) lbz 0,0(5) stb 0,1(3) blr After the patch foo: lbz 0,0(4) lbz 9,0(5) stb 0,0(3) stb 9,1(3) blr Not sure how to add it into testsuite though. Cheers, Bingfeng Mei 2010-10-21 Bingfeng Mei * alias.c (true_dependence_1): Remove check for QImode, which prevents accurate alias info of char pointer type with restrict qualifier. The check is handled by better and more modern method now. (may_alias_p): Ditto. Index: alias.c =================================================================== --- alias.c (revision 165637) +++ alias.c (working copy) @@ -2459,7 +2459,7 @@ true_dependence_1 (const_rtx mem, enum m /* We cannot use aliases_everything_p to test MEM, since we must look at MEM_ADDR, rather than XEXP (mem, 0). */ - if (mem_mode == QImode || GET_CODE (mem_addr) == AND) + if (GET_CODE (mem_addr) == AND) return 1; /* ??? In true_dependence we also allow BLKmode to alias anything. Why @@ -2655,7 +2655,7 @@ may_alias_p (const_rtx mem, const_rtx x) /* We cannot use aliases_everything_p to test MEM, since we must look at MEM_ADDR, rather than XEXP (mem, 0). */ - if (GET_MODE (mem) == QImode || GET_CODE (mem_addr) == AND) + if (GET_CODE (mem_addr) == AND) return 1; if (fixed_scalar_and_varying_struct_p (mem, x, mem_addr, x_addr,