http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47216

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com,
                   |                            |law at redhat dot com,
                   |                            |stevenb.gcc at gmail dot
                   |                            |com
          Component|tree-optimization           |rtl-optimization

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-12 
13:03:18 UTC ---
We have in store-motion.c:

static inline bool
store_killed_in_pat (const_rtx x, const_rtx pat, int after)
{
...
      /* Check for memory stores to aliased objects.  */
      if (MEM_P (dest)
          && !exp_equiv_p (dest, x, 0, true))
        {
          if (after)
            {
              if (output_dependence (dest, x))
                return true;
            }
          else
            {
              if (output_dependence (x, dest))
                return true;
            }
        }

and coming in with

gdb) call debug_rtx (dest)
(mem/s/j:SI (reg/f:DI 67) [0 g_3+0 S4 A32])
(gdb) call debug_rtx (x)
(mem/s/c:SI (reg/f:DI 67) [0 MEM[(int *)&g_3]+0 S4 A32])

and exp_equiv_p returns true.  But then we seem to completely ignore
that kill(!?), thus we happily sink the first store across the second.
Huh.  Doesn't make sense to me unless the SET_SRCs are also equivalent.

Of course it may be that this shouldn't happen because if it does then
the antic sets are not as expected?

I guess it makes sense if you only look at the description for
store_killed_in_pat and adjust it to "looking for any loads which
might make the store in X live" (loads don't kill anything).

Ultimatively this leads to a wrong answer from store_killed_after.

Simplified situation is like

 for (;;)
   {
     *x = 1;
     *x = 2;
   }

and store-motion sinks *x = 1 across *x = 2.

svn blame blames steven for store-motion (of course - he split it out).
Steven - do you by any chance have any idea how it works?  The code
dates back to

2001-04-09  Andrew MacLeod  <amacl...@redhat.com>
           Jeff Law  <l...@redhat.com>

And I'd just do an uninformed

Index: gcc/store-motion.c
===================================================================
--- gcc/store-motion.c  (revision 168707)
+++ gcc/store-motion.c  (working copy)
@@ -367,8 +367,7 @@ store_killed_in_pat (const_rtx x, const_
        dest = XEXP (dest, 0);

       /* Check for memory stores to aliased objects.  */
-      if (MEM_P (dest)
-         && !exp_equiv_p (dest, x, 0, true))
+      if (MEM_P (dest))
        {
          if (after)
            {

Reply via email to