public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35729]  New: const volatile variable accessed that should not be
@ 2008-03-28  3:05 regehr at cs dot utah dot edu
  2008-03-28 10:27 ` [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop rguenth at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: regehr at cs dot utah dot edu @ 2008-03-28  3:05 UTC (permalink / raw)
  To: gcc-bugs

This is for "gcc version 4.3.0 (GCC)" 

func_1() here should never load from g_361 since the loop body never executes:

  const volatile int g_361 = 3L;
  volatile int g_2 = 0L;
  void func_1 (void) {
    for (g_2 = 0; g_2 > 10; g_2++)
      {
        int l_357 = g_361;
      }
  }

However when compiled with "gcc -Os -S foo.c" we get the following output which
does load from g_361:

        .file   "foo.c"
        .text
.globl func_1
        .type   func_1, @function
func_1:
        pushl   %ebp
        movl    %esp, %ebp
        movl    $0, g_2
        movl    g_361, %eax
        jmp     .L2
.L3:
        movl    g_2, %eax
        incl    %eax
        movl    %eax, g_2
.L2:
        movl    g_2, %eax
        cmpl    $10, %eax
        jg      .L3
        popl    %ebp
        ret
        .size   func_1, .-func_1
.globl g_361
        .data
        .align 4
        .type   g_361, @object
        .size   g_361, 4
g_361:
        .long   3
.globl g_2
        .bss
        .align 4
        .type   g_2, @object
        .size   g_2, 4
g_2:
        .zero   4
        .ident  "GCC: (GNU) 4.3.0"
        .section        .note.GNU-stack,"",@progbits

At -O0, -O1, and -O2 there is no problem.


-- 
           Summary: const volatile variable accessed that should not be
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: regehr at cs dot utah dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
@ 2008-03-28 10:27 ` rguenth at gcc dot gnu dot org
  2008-03-30 15:02 ` rakdver at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-28 10:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-03-28 10:26 -------
Confirmed.  RTL loop invariant motion moves the volatile load out of the
function.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rakdver at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
          Component|c                           |rtl-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to fail|                            |4.2.3 4.3.0
      Known to work|                            |4.1.3
   Last reconfirmed|0000-00-00 00:00:00         |2008-03-28 10:26:31
               date|                            |


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
  2008-03-28 10:27 ` [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop rguenth at gcc dot gnu dot org
@ 2008-03-30 15:02 ` rakdver at gcc dot gnu dot org
  2008-03-31 14:21 ` rakdver at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2008-03-30 15:02 UTC (permalink / raw)
  To: gcc-bugs



-- 

rakdver at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rakdver at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-03-28 10:26:31         |2008-03-30 15:02:14
               date|                            |


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
  2008-03-28 10:27 ` [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop rguenth at gcc dot gnu dot org
  2008-03-30 15:02 ` rakdver at gcc dot gnu dot org
@ 2008-03-31 14:21 ` rakdver at gcc dot gnu dot org
  2008-04-01  9:40 ` dominiq at lps dot ens dot fr
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2008-03-31 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rakdver at gcc dot gnu dot org  2008-03-31 14:20 -------
Subject: Bug 35729

Author: rakdver
Date: Mon Mar 31 14:19:52 2008
New Revision: 133755

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133755
Log:
        PR rtl-optimization/35729
        * loop-invariant.c (check_maybe_invariant): Disallow volatile memory
        references.

        * gcc.dg/pr35729.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/pr35729.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/loop-invariant.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (2 preceding siblings ...)
  2008-03-31 14:21 ` rakdver at gcc dot gnu dot org
@ 2008-04-01  9:40 ` dominiq at lps dot ens dot fr
  2008-04-01 10:28 ` dominiq at lps dot ens dot fr
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-04-01  9:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dominiq at lps dot ens dot fr  2008-04-01 09:39 -------
The test fails on i686-apple-darwin9 at revision 133785:

FAIL: gcc.dg/pr35729.c scan-rtl-dump-times loop2_invariant "Decided to move
invariant" 0


-- 


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (3 preceding siblings ...)
  2008-04-01  9:40 ` dominiq at lps dot ens dot fr
@ 2008-04-01 10:28 ` dominiq at lps dot ens dot fr
  2008-04-27 17:18 ` danglin at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-04-01 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from dominiq at lps dot ens dot fr  2008-04-01 10:28 -------
On i686-apple-darwin9, the failure occurs only in 32 bit mode (default). I also
occurs on powerpc-apple-darwin8.5.0:

http://gcc.gnu.org/ml/gcc-testresults/2008-04/msg00013.html


-- 


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (4 preceding siblings ...)
  2008-04-01 10:28 ` dominiq at lps dot ens dot fr
@ 2008-04-27 17:18 ` danglin at gcc dot gnu dot org
  2008-05-25 18:04 ` ghazi at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: danglin at gcc dot gnu dot org @ 2008-04-27 17:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from danglin at gcc dot gnu dot org  2008-04-27 17:17 -------
The test pr35729.c also fails on hppa-unknown-linux-gnu.


-- 

danglin at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (5 preceding siblings ...)
  2008-04-27 17:18 ` danglin at gcc dot gnu dot org
@ 2008-05-25 18:04 ` ghazi at gcc dot gnu dot org
  2008-10-16 21:34 ` sje at cup dot hp dot com
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ghazi at gcc dot gnu dot org @ 2008-05-25 18:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ghazi at gcc dot gnu dot org  2008-05-25 18:03 -------
The testcase also fails for me on x86_64-unknown-linux-gnu or
i686-unknown-linux-gnu but requires -fpic/-fPIC to trigger.  (That may explain
the darwin x86 error.)  See:

x86_64: http://gcc.gnu.org/ml/gcc-testresults/2008-05/msg02221.html
i686: http://gcc.gnu.org/ml/gcc-testresults/2008-05/msg01800.html


-- 

ghazi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ghazi at gcc dot gnu dot org


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (6 preceding siblings ...)
  2008-05-25 18:04 ` ghazi at gcc dot gnu dot org
@ 2008-10-16 21:34 ` sje at cup dot hp dot com
  2008-11-08  1:36 ` danglin at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: sje at cup dot hp dot com @ 2008-10-16 21:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from sje at cup dot hp dot com  2008-10-16 21:32 -------
The new test that was added fails for me on ia64-*-* platforms too.  It looks
like the fix for the original bug is right in that it is preventing the
volatile assignment in being moved but the test is bad because other
instructions (not involving the volatile variable) are being moved out of the
loop so the test does see the "Decided to move invariant" string in the loop
dump file.  The information in this file doesn't seem to be specific enough to
allow for an easy way to check whether the assignment of g_361 specifically was
or was not moved.  If I compile with -O2 instead of -Os then I don't see any
invariant code motion but I don't know if that is a way to fix the test or not
since the original bug involved -Os.


-- 

sje at cup dot hp dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sje at cup dot hp dot com


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (7 preceding siblings ...)
  2008-10-16 21:34 ` sje at cup dot hp dot com
@ 2008-11-08  1:36 ` danglin at gcc dot gnu dot org
  2008-11-08 20:20 ` ebotcazou at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: danglin at gcc dot gnu dot org @ 2008-11-08  1:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from danglin at gcc dot gnu dot org  2008-11-08 01:34 -------
The test pr35729.c also fails on hppa64-hp-hpux11.11.


-- 


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (8 preceding siblings ...)
  2008-11-08  1:36 ` danglin at gcc dot gnu dot org
@ 2008-11-08 20:20 ` ebotcazou at gcc dot gnu dot org
  2008-12-02 14:22 ` krebbel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-08 20:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ebotcazou at gcc dot gnu dot org  2008-11-08 20:19 -------
> The test pr35729.c also fails on hppa64-hp-hpux11.11.

Same on the SPARC.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (9 preceding siblings ...)
  2008-11-08 20:20 ` ebotcazou at gcc dot gnu dot org
@ 2008-12-02 14:22 ` krebbel at gcc dot gnu dot org
  2009-01-05 23:15 ` sje at cup dot hp dot com
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: krebbel at gcc dot gnu dot org @ 2008-12-02 14:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from krebbel at gcc dot gnu dot org  2008-12-02 14:19 -------
Fails on s390 and s390x as well.


-- 

krebbel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |krebbel at gcc dot gnu dot
                   |                            |org


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (10 preceding siblings ...)
  2008-12-02 14:22 ` krebbel at gcc dot gnu dot org
@ 2009-01-05 23:15 ` sje at cup dot hp dot com
  2009-01-17  2:50 ` ghazi at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: sje at cup dot hp dot com @ 2009-01-05 23:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from sje at cup dot hp dot com  2009-01-05 23:15 -------
Zdenek, are you still looking at this bug?  As I mention in comment #7, I think
the fix that is checked in is good, it is just the test that is bad.  I don't
see a good way to fix the test, I would support just removing the test, though
I can't actually approve such a change.  Do you see a better way to address the
problem of the failing test?


-- 


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (11 preceding siblings ...)
  2009-01-05 23:15 ` sje at cup dot hp dot com
@ 2009-01-17  2:50 ` ghazi at gcc dot gnu dot org
  2009-01-19 18:53 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ghazi at gcc dot gnu dot org @ 2009-01-17  2:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from ghazi at gcc dot gnu dot org  2009-01-17 02:50 -------
Reconfirming for (x86 && pic):

http://gcc.gnu.org/ml/gcc-testresults/2009-01/msg01601.html


-- 

ghazi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2008-03-30 15:02:14         |2009-01-17 02:50:47
               date|                            |


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (12 preceding siblings ...)
  2009-01-17  2:50 ` ghazi at gcc dot gnu dot org
@ 2009-01-19 18:53 ` ubizjak at gmail dot com
  2009-11-29 16:22 ` ghazi at gcc dot gnu dot org
  2009-11-29 16:38 ` rguenth at gcc dot gnu dot org
  15 siblings, 0 replies; 17+ messages in thread
From: ubizjak at gmail dot com @ 2009-01-19 18:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from ubizjak at gmail dot com  2009-01-19 18:53 -------
(In reply to comment #10)
> Fails on s390 and s390x as well.

And alpha.


-- 


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (13 preceding siblings ...)
  2009-01-19 18:53 ` ubizjak at gmail dot com
@ 2009-11-29 16:22 ` ghazi at gcc dot gnu dot org
  2009-11-29 16:38 ` rguenth at gcc dot gnu dot org
  15 siblings, 0 replies; 17+ messages in thread
From: ghazi at gcc dot gnu dot org @ 2009-11-29 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from ghazi at gcc dot gnu dot org  2009-11-29 16:21 -------
This testcase was "fixed" here:
http://gcc.gnu.org/ml/gcc-patches/2009-01/msg01134.html

Can we close this one?


-- 

ghazi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |WAITING


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


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

* [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop
  2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
                   ` (14 preceding siblings ...)
  2009-11-29 16:22 ` ghazi at gcc dot gnu dot org
@ 2009-11-29 16:38 ` rguenth at gcc dot gnu dot org
  15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-29 16:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from rguenth at gcc dot gnu dot org  2009-11-29 16:38 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
      Known to fail|4.2.3 4.3.0 4.4.0           |4.2.3 4.3.0
      Known to work|4.1.3                       |4.1.3 4.4.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


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


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

end of thread, other threads:[~2009-11-29 16:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-28  3:05 [Bug c/35729] New: const volatile variable accessed that should not be regehr at cs dot utah dot edu
2008-03-28 10:27 ` [Bug rtl-optimization/35729] const volatile variable access incorrectly hoisted out of loop rguenth at gcc dot gnu dot org
2008-03-30 15:02 ` rakdver at gcc dot gnu dot org
2008-03-31 14:21 ` rakdver at gcc dot gnu dot org
2008-04-01  9:40 ` dominiq at lps dot ens dot fr
2008-04-01 10:28 ` dominiq at lps dot ens dot fr
2008-04-27 17:18 ` danglin at gcc dot gnu dot org
2008-05-25 18:04 ` ghazi at gcc dot gnu dot org
2008-10-16 21:34 ` sje at cup dot hp dot com
2008-11-08  1:36 ` danglin at gcc dot gnu dot org
2008-11-08 20:20 ` ebotcazou at gcc dot gnu dot org
2008-12-02 14:22 ` krebbel at gcc dot gnu dot org
2009-01-05 23:15 ` sje at cup dot hp dot com
2009-01-17  2:50 ` ghazi at gcc dot gnu dot org
2009-01-19 18:53 ` ubizjak at gmail dot com
2009-11-29 16:22 ` ghazi at gcc dot gnu dot org
2009-11-29 16:38 ` rguenth at gcc dot gnu dot 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).