This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question on PR36873


Hi,

We just got a similar problem on Blackfin GCC recently. Let me take the test code from the bug as an example:

typedef unsigned short u16;
typedef unsigned int u32;

u32 a(volatile u16* off) {
        return *off;
}

u32 b(u16* off) {
        return *off;
}

compiled with
mingw32-gcc-4.3.0.exe -c -O2 -fomit-frame-pointer -mtune=core2 test.c

it produces:
00000000 <_a>:
   0:   8b 44 24 04             mov    0x4(%esp),%eax
   4:   0f b7 00                movzwl (%eax),%eax
   7:   0f b7 c0                movzwl %ax,%eax  <== The redundant insn
   a:   c3                      ret

00000010 <_b>:
  10:   8b 44 24 04             mov    0x4(%esp),%eax
  14:   0f b7 00                movzwl (%eax),%eax
  17:   c3                      ret

I don't understand Richard's comment. What do we not optimize volatile accesses in this test case. I know we cannot do many optimizations on volatile accesses, but I think it's OK to remove the redundant insn in this case. Could someone provide me a case in which we cannot remove it.


Thanks, Jie


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]