public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bingfeng Mei" <bmei@broadcom.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: "Richard Guenther" <richard.guenther@gmail.com>,
	"zsojka@seznam.cz" <zsojka@seznam.cz>,
	"eres@il.ibm.com" <eres@il.ibm.com>
Subject: [PATCH] PR45834: make restrict qualifier work for char pointer type.
Date: Thu, 21 Oct 2010 16:03:00 -0000	[thread overview]
Message-ID: <7FB04A5C213E9943A72EE127DB74F0ADA691645C5F@SJEXCHCCR02.corp.ad.broadcom.com> (raw)

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  <bmei@broadcom.com>
	* 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,



             reply	other threads:[~2010-10-21 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 16:03 Bingfeng Mei [this message]
2010-10-21 16:25 ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7FB04A5C213E9943A72EE127DB74F0ADA691645C5F@SJEXCHCCR02.corp.ad.broadcom.com \
    --to=bmei@broadcom.com \
    --cc=eres@il.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=zsojka@seznam.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).