public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/45704]  New: [4.5 Regression] load byte instruction is used for volatile int
@ 2010-09-17 14:49 anemo at mba dot ocn dot ne dot jp
  2010-09-17 15:45 ` [Bug tree-optimization/45704] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: anemo at mba dot ocn dot ne dot jp @ 2010-09-17 14:49 UTC (permalink / raw)
  To: gcc-bugs

A cast to volatile int pointer is ignored on gcc 4.5 with this test case.

struct st {
        int ptr;
};

int foo(struct st *st)
{
        int v = *(volatile int *)&st->ptr;
        return v & 0xff;
}

mipsel-linux-gcc-4.5.1 -O2 foo.c -S output:
        lbu     $2,0($4)
        j       $31
        nop

It seems the cast are ignored and "load int and mask" was optimized to "load
byte".
gcc 4.4.4 works fine.
mipsel-linux-gcc-4.4.4 -O2 foo.c -S output:
        lw      $2,0($4)
        j       $31
        andi    $2,$2,0x00ff

git-bisect tell me 0d9f1189f3df5ce5c0efc3ecadc7c0a4f75b202d is the first bad
commit.
URL: http://gcc.gnu.org/viewcvs?view=revision&revision=156571
The commit is fix for Bug 42956.

The PR 42956 bugzilla shows same fix was applied to both 4.5.0 and 4.4.4,
but they behave differently on this test case.

Comparing patches for 4.4 branch and 4.5, I see the latter contains two more
changes for gimplify.c:
A STRIP_NOP line and lines starting with "/* *(foo *)&complexfoo => __real__
complexfoo */" comment.

I do not know gcc internal at all but it seems reverting this change fixes this
problem.

-  STRIP_USELESS_TYPE_CONVERSION (sub);
+  STRIP_NOPS (sub);

Hope this helps.


-- 
           Summary: [4.5 Regression] load byte instruction is used for
                    volatile int
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anemo at mba dot ocn dot ne dot jp


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


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

end of thread, other threads:[~2011-02-03 18:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-45704-4@http.gcc.gnu.org/bugzilla/>
2010-09-27 18:12 ` [Bug tree-optimization/45704] [4.5 Regression] load byte instruction is used for volatile int anemo at mba dot ocn.ne.jp
2010-09-27 18:14 ` rguenther at suse dot de
2010-09-28 18:31 ` anemo at mba dot ocn.ne.jp
2010-09-30 18:47 ` anemo at mba dot ocn.ne.jp
2010-09-30 18:51 ` rguenther at suse dot de
2010-10-01 12:48 ` anemo at mba dot ocn.ne.jp
2011-02-03 18:28 ` tschwinge at gcc dot gnu.org
2010-09-17 14:49 [Bug tree-optimization/45704] New: " anemo at mba dot ocn dot ne dot jp
2010-09-17 15:45 ` [Bug tree-optimization/45704] " rguenth at gcc dot gnu dot org
2010-09-20 15:54 ` rguenth at gcc dot gnu dot org
2010-09-21 10:48 ` rguenth at gcc dot gnu dot org
2010-09-21 10:48 ` 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).