gcc-4.5 -O2 -m32 misoptimizes sha256: $ ~/gcc/install/bin/gcc-4.5 sha256.c -L/home/edwin/gcc/install/lib/gcc/x86_64-unknown-linux-gnu/lib32 -O2 -m32 $ ./a.out sha256 test vector #1 failed sha256 test vector #2 failed sha256 test vector #3 failed Aborted Without -m32 it works: $ ~/gcc/install/bin/gcc-4.5 sha256.c -L/home/edwin/gcc/install/lib/gcc/x86_64-unknown-linux-gnu/lib64 -O2 $ ./a.out $ And -m32 -O1 works too: $ ~/gcc/install/bin/gcc-4.5 sha256.c -L/home/edwin/gcc/install/lib/gcc/x86_64-unknown-linux-gnu/lib32 -O1 -m32 $ ./a.out $ gcc version: ~/gcc/install/bin/gcc-4.5 -v Using built-in specs. COLLECT_GCC=/home/edwin/gcc/install/bin/gcc-4.5 COLLECT_LTO_WRAPPER=/home/edwin/gcc/install/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --enable-languages=c --enable-checking=release --enable-ssp --disable-libssp --disable-plugin --disable-libmudflap --with-system-zlib --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex -without-system-libunwind --with-arch-32=i586 --with-tune=generic --with-mpfr=/opt/cfarm/mpfr-2.4.1 --with-gmp=/opt/cfarm/gmp-4.2.4 --with-libelf=/opt/cfarm/libelf-0.8.12 --with-mpc=/opt/cfarm/mpc-0.8 --disable-bootstrap : (reconfigured) ../gcc-trunk/configure --prefix=/home/edwin/gcc/install --enable-languages=c --enable-checking=release --enable-ssp --disable-libssp --disable-plugin --disable-libmudflap --with-system-zlib --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex -without-system-libunwind --with-arch-32=i586 --with-tune=generic --with-mpfr=/opt/cfarm/mpfr-2.4.1 --with-gmp=/opt/cfarm/gmp-4.2.4 --with-libelf=/opt/cfarm/libelf-0.8.12 --with-mpc=/opt/cfarm/mpc-0.8 --disable-bootstrap Thread model: posix gcc version 4.5.0 20100307 (experimental) (GCC) Bug initially reported against openSUSE 11.3 factory's gcc-4.5, but I reproduced with upstream gcc-4.5 SVN r157262. See https://wwws.clamav.net/bugzilla/show_bug.cgi?id=1862 for the original report.
Created attachment 20038 [details] sha256.c
Created attachment 20039 [details] preprocessed sha256.c
Confirmed. This is exposed by the new bswap pass.
It is caused by revision 148848: http://gcc.gnu.org/ml/gcc-cvs/2009-06/msg00831.html
Created attachment 20074 [details] Experimental patch This patch fixes the problem for me. Testsuites are still running.
(In reply to comment #5) > Created an attachment (id=20074) [edit] > Experimental patch > > This patch fixes the problem for me. Testsuites are still running. > Why does the new testcase have +/* { dg-require-effective-target lp64 } */ when the failure is shown with -m32 on x86-64?
Subject: Bug 43280 Author: krebbel Date: Thu Mar 11 13:51:00 2010 New Revision: 157386 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157386 Log: 2010-03-11 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> PR tree-optimization/43280 * tree-ssa-math-opts.c (find_bswap_1): Modify symbolic number generation. Move calculation of size out of the if branch. (find_bswap): Modify compare number generation. 2010-03-11 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * gcc.dg/optimize-bswapdi-1.c: Add OpenSSL bswap variant. * gcc.dg/pr43280.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/pr43280.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c trunk/gcc/tree-ssa-math-opts.c
(In reply to comment #6) > Why does the new testcase have > > +/* { dg-require-effective-target lp64 } */ > > when the failure is shown with -m32 on x86-64? > I've removed that in the new version. Thanks!