Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.4/specs Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada --disable-checking --libdir=/usr/lib --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux Thread model: posix gcc version 3.3.4 (pre 3.3.5 20040809) /usr/lib/gcc-lib/i586-suse-linux/3.3.4/cc1 -E -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=4 muldiv.c -march=pentium -O3 muldiv.i #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/lib/gcc-lib/i586-suse-linux/3.3.4/include /usr/i586-suse-linux/include /usr/include End of search list. /usr/lib/gcc-lib/i586-suse-linux/3.3.4/cc1 -fpreprocessed muldiv.i -quiet -dumpbase muldiv.c -march=pentium -auxbase muldiv -O3 -version -o muldiv.s GNU C version 3.3.4 (pre 3.3.5 20040809) (i586-suse-linux) compiled by GNU C version 3.3.4 (pre 3.3.5 20040809). GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=63486
When compiling the following function: gcc -O3 -S -march=pentium int vat(int a) { return a * 47 / 40; } optimising misses the trick of combining the multiply and divide into a single multiply and shift arithmetic right. # assume value is already in EAX movl 1261646643,%ecx imul %ecx sarl $30 # I mean shift %edx,%eax pair right by 30 bits I realise I haven't chosen the value properly to give the same results as an overflow when multiplying by 47, but is that defined in the standard? -- Summary: optimising muldiv() type operations Product: gcc Version: 3.3.4 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ajrobb at bigfoot dot com CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: SuSE Linux 9.2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20283