public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR45834: make restrict qualifier work for char pointer type.
@ 2010-10-21 16:03 Bingfeng Mei
  2010-10-21 16:25 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Bingfeng Mei @ 2010-10-21 16:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Guenther, zsojka, eres

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,



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] PR45834: make restrict qualifier work for char pointer type.
  2010-10-21 16:03 [PATCH] PR45834: make restrict qualifier work for char pointer type Bingfeng Mei
@ 2010-10-21 16:25 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2010-10-21 16:25 UTC (permalink / raw)
  To: Bingfeng Mei; +Cc: gcc-patches, zsojka, eres

On Thu, Oct 21, 2010 at 4:26 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> 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.

Just say

        * alias.c (true_dependence_1): Remove obsolete check for QImode.

Ok with that change.

Richard.


> 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,
>
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-21 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-21 16:03 [PATCH] PR45834: make restrict qualifier work for char pointer type Bingfeng Mei
2010-10-21 16:25 ` Richard Guenther

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).