gcc (GCC) 4.0.0 20050316 (prerelease) (from the gcc-4_0-branch branch) emits
bad code for DImode left shifts by 31 and then 1 (foo << 31 <<1).  Instead of
doing the shifts, both the lowpart (correctly) and the highpart (incorrectly)
word get zeroed.  If the shifts are replaced by ones by 30 and then 2 or by one
by 32, then the resulting code is correct.

 GCC has been built with the following configure and make options:

$ CC=i386-linux-gcc \
CXX=i386-linux-g++ \
F77=i386-linux-gfortran \
CFLAGS="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
CXXFLAGS="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
FCFLAGS="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
CC_FOR_BUILD=i386-linux-gcc \
CFLAGS_FOR_BUILD="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
CFLAGS_FOR_TARGET="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
CXXFLAGS_FOR_TARGET="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
FCFLAGS_FOR_TARGET="-pipe -O2 -fomit-frame-pointer -mtune=i486" \
INSTALL_PROGRAM='${INSTALL} -s' \
../configure --prefix=/usr --mandir='${datadir}/man' \
--with-local-prefix='${prefix}/local' \
--enable-shared \
--with-slibdir=/lib \
--enable-static \
--with-system-zlib \
--enable-threads \
--cache-file=config.cache \
--build=i386-linux --host=i386-linux --target=i386-linux
$ make 'BOOT_CFLAGS=-pipe -O2 -fomit-frame-pointer -mtune=i486' \
'STAGE1_CFLAGS=-pipe -O2 -fomit-frame-pointer -mtune=i486' \
'GCJFLAGS=-pipe -O2 -fomit-frame-pointer -mtune=i486' \
CXX_FOR_BUILD=i386-linux-g++ \
'CXXFLAGS_FOR_BUILD=-pipe -O2 -fomit-frame-pointer -mtune=i486' bootstrap

 Here is a simple test case that fails for me (the source C file only as you
seem not to want to receive *.s files):

unsigned long long int badshift(unsigned long long int v)
{
        return v << 31 << 1;
}

 The problem was originally discovered with a 4.0.0 snapshot from the trunk
dated 20050225, therefore it likely applies to 4.1.0, too.

-- 
           Summary: Bad code for DImode left shifts by 31 and then 1
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: macro at linux-mips dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


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

Reply via email to