Patchwork Fix PR57341

login
register
mail settings
Submitter Richard Guenther
Date May 23, 2013, 7:58 a.m.
Message ID <alpine.LNX.2.00.1305230956120.24881@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/245834/
State New
Headers show

Comments

Richard Guenther - May 23, 2013, 7:58 a.m.
When trying to figure out whether it can re-materialize a memory
load before the use in

   <read> ... = equiv_mem;
   <write> dest = ...;
        <use>

IRA manages to get alias queries wrong by using true_dependence
(which is for read-after-write) instead of anti_dependence as
it wants to test whether the write invalidates equiv_mem.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?
Ok for the 4.8 branch at this point?

Thanks,
Richard.

2013-05-23  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/57341
	* ira.c (validate_equiv_mem_from_store): Use anti_dependence
	instead of true_dependence.

	* gcc.dg/torture/pr57341.c: New testcase.

Index: gcc/testsuite/gcc.dg/torture/pr57341.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr57341.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr57341.c	(revision 0)
***************
*** 0 ****
--- 1,22 ----
+ /* { dg-do run } */ 
+ /* { dg-additional-options "-msse" { target sse2_runtime } } */
+ 
+ int a, d;
+ int *b = &a, **c;
+ int
+ main ()
+ {
+   int e;
+     {
+       int f[4];
+       for (d = 0; d < 4; d++)
+ 	f[d] = 1;
+       e = f[1];
+     }
+   int *g[28] = { };
+   *b = e;
+   c = &g[0];
+   if (a != 1)
+     __builtin_abort ();
+   return 0;
+ }
Jakub Jelinek - May 23, 2013, 8:26 a.m.
On Thu, May 23, 2013 at 09:58:50AM +0200, Richard Biener wrote:
> 2013-05-23  Richard Biener  <rguenther@suse.de>
> 
> 	PR rtl-optimization/57341
> 	* ira.c (validate_equiv_mem_from_store): Use anti_dependence
> 	instead of true_dependence.
> 
> 	* gcc.dg/torture/pr57341.c: New testcase.

Ok, thanks.

	Jakub

Patch

Index: gcc/ira.c
===================================================================
--- gcc/ira.c	(revision 199199)
+++ gcc/ira.c	(working copy)
@@ -2520,7 +2520,7 @@  validate_equiv_mem_from_store (rtx dest,
   if ((REG_P (dest)
        && reg_overlap_mentioned_p (dest, equiv_mem))
       || (MEM_P (dest)
-	  && true_dependence (dest, VOIDmode, equiv_mem)))
+	  && anti_dependence (equiv_mem, dest)))
     equiv_mem_modified = 1;
 }