public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/58145] New: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations
@ 2013-08-13  2:38 hp at gcc dot gnu.org
  2013-08-13 22:56 ` [Bug middle-end/58145] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hp at gcc dot gnu.org @ 2013-08-13  2:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58145
           Summary: [Regression]: volatileness of write is discarded,
                    perhaps in "lim1" related to loop optimizations
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hp at gcc dot gnu.org
            Target: cris-*-*, crisv32-*-*

Created attachment 30640
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30640&action=edit
Preprocessed code; compile at -O2, e.g. "cc1 -O2 y.i -o y.s"

The exact version in which the bug appeared is not yet triaged: it's present on
r201675 of trunk, r201652 of the 4.8 branch, r190527 of the 4.7 branch (!) but
appears to not be present in r135713 of the 4.3 branch (!).

The bug is that the volatileness of the dereference of the write (the
assignment through a pointer to a volatile structure) in function pb_out is
discarded, leaving a single write after the loop.  Note also that together with
the discarded-volatileness-bug there seems to be a missed-optimization-bug in
that the loop is redundant; the loop awkwardly computes iterates over 0..31 and
computes 1<<i but the intermediate computations aren't used; then the last
value is written after the loop. Editing the code to manually inline pb_out
makes no difference to the bug.

The wrong code is evident already in the .expand dump on trunk (according to
-da).  It is not present (according to -fdump-tree-all-all) in
y.i.096t.loopinit but appears present in y.i.097t.lim1.

Until someone (including myself) has repeated the observation for another
target, I'll set the target-specifier to cris*-* but it seems obviously
generic, affecting all targets.


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

* [Bug middle-end/58145] [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations
  2013-08-13  2:38 [Bug middle-end/58145] New: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations hp at gcc dot gnu.org
@ 2013-08-13 22:56 ` jakub at gcc dot gnu.org
  2013-08-14 10:09 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-13 22:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30648
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30648&action=edit
untested fix

Seems to be a tree-sra.c bug to me.  Untested fix attached, with no testcase
yet etc.


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

* [Bug middle-end/58145] [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations
  2013-08-13  2:38 [Bug middle-end/58145] New: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations hp at gcc dot gnu.org
  2013-08-13 22:56 ` [Bug middle-end/58145] " jakub at gcc dot gnu.org
@ 2013-08-14 10:09 ` jakub at gcc dot gnu.org
  2013-08-14 20:37 ` jakub at gcc dot gnu.org
  2013-08-16  1:32 ` hp at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-14 10:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #30648|0                           |1
        is obsolete|                            |

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30653
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30653&action=edit
gcc49-pr58145.patch

Updated patch.


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

* [Bug middle-end/58145] [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations
  2013-08-13  2:38 [Bug middle-end/58145] New: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations hp at gcc dot gnu.org
  2013-08-13 22:56 ` [Bug middle-end/58145] " jakub at gcc dot gnu.org
  2013-08-14 10:09 ` jakub at gcc dot gnu.org
@ 2013-08-14 20:37 ` jakub at gcc dot gnu.org
  2013-08-16  1:32 ` hp at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-14 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed Aug 14 20:34:56 2013
New Revision: 201748

URL: http://gcc.gnu.org/viewcvs?rev=201748&root=gcc&view=rev
Log:
    PR tree-optimization/58145
    * tree-sra.c (build_ref_for_offset): If prev_base has
    TREE_THIS_VOLATILE or TREE_SIDE_EFFECTS, propagate it to MEM_REF.

    * gcc.dg/pr58145-1.c: New test.
    * gcc.dg/pr58145-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr58145-1.c
    trunk/gcc/testsuite/gcc.dg/pr58145-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c

Author: jakub
Date: Wed Aug 14 20:36:12 2013
New Revision: 201749

URL: http://gcc.gnu.org/viewcvs?rev=201749&root=gcc&view=rev
Log:
    PR tree-optimization/58145
    * tree-sra.c (build_ref_for_offset): If prev_base has
    TREE_THIS_VOLATILE or TREE_SIDE_EFFECTS, propagate it to MEM_REF.

    * gcc.dg/pr58145-1.c: New test.
    * gcc.dg/pr58145-2.c: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/pr58145-1.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/pr58145-2.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-sra.c


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

* [Bug middle-end/58145] [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations
  2013-08-13  2:38 [Bug middle-end/58145] New: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations hp at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-08-14 20:37 ` jakub at gcc dot gnu.org
@ 2013-08-16  1:32 ` hp at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: hp at gcc dot gnu.org @ 2013-08-16  1:32 UTC (permalink / raw)
  To: gcc-bugs

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

Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|cris-*-*, crisv32-*-*       |

--- Comment #5 from Hans-Peter Nilsson <hp at gcc dot gnu.org> ---
Formally repeated (using the F17 cut of 4.7.2 (gcc-4.7.2-2.fc17.x86_64) and
trunk of r200585 on x86_64-linux) as not target-specific.


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

end of thread, other threads:[~2013-08-16  1:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-13  2:38 [Bug middle-end/58145] New: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations hp at gcc dot gnu.org
2013-08-13 22:56 ` [Bug middle-end/58145] " jakub at gcc dot gnu.org
2013-08-14 10:09 ` jakub at gcc dot gnu.org
2013-08-14 20:37 ` jakub at gcc dot gnu.org
2013-08-16  1:32 ` hp 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).