public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/47575] New: store-motion removes global stores from endless loops
@ 2011-02-01 16:21 rguenth at gcc dot gnu.org
  2011-02-01 16:26 ` [Bug tree-optimization/47575] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-01 16:21 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: store-motion removes global stores from endless loops
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org


void foo (int *k) 
{
  for (;;)
    *k = 0;
}

is optimized to

foo (int * k)
{
  int k__lsm.2;

<bb 2>:
  k__lsm.2_4 = MEM[(int *)k_1(D)];

<bb 3>:
  k__lsm.2_6 = 0;

<bb 4>:
  goto <bb 3>;

}

by LIM, removing the global store.  We can use is_hidden_global_store
or friends and require at least one exit if that is true for a sm ref.


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

* [Bug tree-optimization/47575] store-motion removes global stores from endless loops
  2011-02-01 16:21 [Bug tree-optimization/47575] New: store-motion removes global stores from endless loops rguenth at gcc dot gnu.org
@ 2011-02-01 16:26 ` rguenth at gcc dot gnu.org
  2011-02-01 17:13 ` rakdver at gcc dot gnu.org
  2021-07-07 11:55 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-01 16:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.02.01 16:25:49
                 CC|                            |rakdver at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-01 16:25:49 UTC ---
Something like

Index: tree-ssa-loop-im.c
===================================================================
--- tree-ssa-loop-im.c  (revision 169487)
+++ tree-ssa-loop-im.c  (working copy)
@@ -2329,7 +2329,10 @@ can_sm_ref_p (struct loop *loop, mem_ref
   base = get_base_address (ref->mem);
   if ((tree_could_trap_p (ref->mem)
        || (DECL_P (base) && TREE_READONLY (base)))
-      && !ref_always_accessed_p (loop, ref, true))
+      && (!ref_always_accessed_p (loop, ref, true))
+          || (TREE_CODE (base) == MEM_REF
+             && ptr_deref_may_alias_global_p (TREE_OPERAND (base, 0))
+             && !loop->exits->e))
     return false;

   /* And it must be independent on all other memory references

minus introducing a new predicate loop_has_no_exit_p ().


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

* [Bug tree-optimization/47575] store-motion removes global stores from endless loops
  2011-02-01 16:21 [Bug tree-optimization/47575] New: store-motion removes global stores from endless loops rguenth at gcc dot gnu.org
  2011-02-01 16:26 ` [Bug tree-optimization/47575] " rguenth at gcc dot gnu.org
@ 2011-02-01 17:13 ` rakdver at gcc dot gnu.org
  2021-07-07 11:55 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rakdver at gcc dot gnu.org @ 2011-02-01 17:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zdenek Dvorak <rakdver at gcc dot gnu.org> 2011-02-01 16:56:57 UTC ---
There is nothing in C standard requiring us to preserve global stores that are
unused, unless they are volatile.  Store motion is by far not the only
optimization in gcc that affects global stores.  That this happens in an
endless loop is not important.


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

* [Bug tree-optimization/47575] store-motion removes global stores from endless loops
  2011-02-01 16:21 [Bug tree-optimization/47575] New: store-motion removes global stores from endless loops rguenth at gcc dot gnu.org
  2011-02-01 16:26 ` [Bug tree-optimization/47575] " rguenth at gcc dot gnu.org
  2011-02-01 17:13 ` rakdver at gcc dot gnu.org
@ 2021-07-07 11:55 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-07 11:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47575

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed, nothing to see here.

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

end of thread, other threads:[~2021-07-07 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 16:21 [Bug tree-optimization/47575] New: store-motion removes global stores from endless loops rguenth at gcc dot gnu.org
2011-02-01 16:26 ` [Bug tree-optimization/47575] " rguenth at gcc dot gnu.org
2011-02-01 17:13 ` rakdver at gcc dot gnu.org
2021-07-07 11:55 ` rguenth at gcc dot gnu.org

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