The following code produces a redundant "movzwl":

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
   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 also saw this behavior in Ubuntu 7.10 using gcc 4.1.3

complete version of used gcc:
mingw32-gcc-4.3.0.exe -v
Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.3.0/configure
--enable-languages=c,ada,c++,fortran,java,objc,obj-c++
--disable-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp
--with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug
--enable-concept-checks --enable-version-specific-runtime-libs --build=mingw32
--with-bugurl=http://www.mingw.org/bugs.shtml --prefix=/mingw
--with-gmp=/mingw/src/gcc/gmp-mpfr-root
--with-mpfr=/mingw/src/gcc/gmp-mpfr-root
--with-libiconv-prefix=/mingw/src/gcc/libiconv-root
Thread model: win32
gcc version 4.3.0 20080305 (alpha-testing) mingw-20080502 (GCC)


-- 
           Summary: redundant movzwl for volatile unsigned short load
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: MatthiasMann at gmx dot de
  GCC host triplet: Microsoft Windows XP [Version 5.1.2600]
GCC target triplet: mingw32


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

Reply via email to