https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61267
Bug ID: 61267
Summary: [MIPS] -march=mips32 does not always disable the use
of branch likely instructions
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: joel.porquet at gmail dot com
The symptom of this bug is that even when specifying "-march=mips32", which is
normally supposed to disable the use of branch likely instructions (according
to the man page), branch likely instructions can still be generated by gcc. It
occurs when specifying "-Os" optimization option.
---
My crosscompilation toolchain was generated with the following options:
Configured with: /home/joel/work/crosstool-test/_build/src/gcc-4.8.2/configure
--build=x86_64-build_unknown-linux-gnu --host=x86_64-build_unknown-linux-gnu
--target=mipsel-tsar-linux-uclibc
--prefix=/home/joel/work/crosstool-test/x-tools/mipsel-tsar-linux-uclibc
--with-sysroot=/home/joel/work/crosstool-test/x-tools/mipsel-tsar-linux-uclibc/mipsel-tsar-linux-uclibc/sysroot
--enable-languages=c --with-arch=mips32 --with-abi=32 --with-tune=mips32
--with-float=soft --with-pkgversion='crosstool-NG hg+default-000000000000'
--enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp
--disable-libquadmath --disable-libquadmath-support
--with-gmp=/home/joel/work/crosstool-test/_build/mipsel-tsar-linux-uclibc/buildtools
--with-mpfr=/home/joel/work/crosstool-test/_build/mipsel-tsar-linux-uclibc/buildtools
--with-mpc=/home/joel/work/crosstool-test/_build/mipsel-tsar-linux-uclibc/buildtools
--with-isl=/home/joel/work/crosstool-test/_build/mipsel-tsar-linux-uclibc/buildtools
--with-cloog=/home/joel/work/crosstool-test/_build/mipsel-tsar-linux-uclibc/buildtools
--with-libelf=/home/joel/work/crosstool-test/_build/mipsel-tsar-linux-uclibc/buildtools
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--enable-threads=posix --disable-nls --disable-multilib
--with-local-prefix=/home/joel/work/crosstool-test/x-tools/mipsel-tsar-linux-uclibc/mipsel-tsar-linux-uclibc/sysroot
--enable-c99 --enable-long-long
---
When running gcc -v -Q --help=target, the output (I only selected what seemed
to be the relevant parts) says:
-mabi=ABI 32
-mabicalls [enabled]
-march=ISA mips32
-mbranch-likely [disabled]
-msoft-float [enabled]
-mtune=PROCESSOR mips32
-muclibc [enabled]
But now, if I try to compile a program with the "-Os" option, -mbranch-likely
option is enabled by default, even if -march=mips32 is explicitely set as well:
$ gcc -march=mips32 -v -Q -Os -c -o test.o test.c
options enabled: ...
-mbranch-likely
...
---
Once again, according to the man page, branch likely instructions are supposed
to be avoided when compiling for mips32:
"An exception is for the MIPS32 and MIPS64 architectures and processors that
implement those architectures; for those, Branch Likely instructions are not be
generated by default because the MIPS32 and MIPS64 architectures specifically
deprecate their use."
So, is it normal behavior? Shouldn't "-mbranch-likely" not be specified when
compiling for MIPS32 even with "-Os"?
Thanks.