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

             Bug #: 52483
           Summary: SH Target: Loads from volatile memory leave redundant
                    sign/zero extensions
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: olege...@gcc.gnu.org
                CC: kkoj...@gcc.gnu.org
            Target: sh*-*-*


The following cases seem to happen at any optimization level:

int test_0 (volatile char* x)
{
  return *x == 5;
}

mov.b   @r4,r0  ! 6     *extendqisi2_compact/2    [length = 2]
exts.b  r0,r0   ! 7     *extendqisi2_compact/1    [length = 2]
cmp/eq  #5,r0   ! 8     cmpeqsi_t/2    [length = 2]
rts             ! 27    *return_i    [length = 2]
movt    r0      ! 14    movsi_ie/10    [length = 2]


int test_1 (volatile unsigned char* x)
{
  return *x == 0x80;
}

mov.b   @r4,r0    ! 6   *extendqisi2_compact/2    [length = 2]
exts.b  r0,r0     ! 8   *extendqisi2_compact/1    [length = 2]
cmp/eq  #-128,r0  ! 9   cmpeqsi_t/2    [length = 2]
rts               ! 28  *return_i    [length = 2]
movt    r0      ! 15  movsi_ie/10    [length = 2]


The same also happens for HImode.
Maybe a few peepholes would help here?

Using built-in specs.
COLLECT_GCC=sh-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sh-elf/4.8.0/lto-wrapper
Target: sh-elf
Configured with: ../gcc-trunk/configure --target=sh-elf --prefix=/usr/local
--enable-languages=c,c++ --enable-multilib --disable-libssp --disable-nls
--disable-werror --enable-lto --with-newlib --with-gnu-as --with-gnu-ld
--with-system-zlib
Thread model: single
gcc version 4.8.0 20120304 (experimental) (GCC)

Reply via email to