http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49263
Summary: SH Target: underutilized "TST #imm, R0" instruction
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 24411
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24411
test for various integer types and constant values 0...255
The "TST #imm, R0" instruction is a bit underutilized on SH targets. For some
bit patterns of the immediate constant it tries to extract the bits in question
by various means and test the result against zero/non-zero and misses the
straight forward instruction.
In particular:
* one single bit
* n contiguous bits starting at bit 0
When testing a byte against 0x80 it uses "CMP/PZ", which is as good as a "TST"
instruction (in terms of costs), so this is OK.
I've spotted this in version around 4.4. It still happens with 4.6 and the
following config:
Using built-in specs.
COLLECT_GCC=sh-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sh-elf/4.6.1/lto-wrapper
Target: sh-elf
Configured with: ../gcc-4.6-20110527/configure --target=sh-elf
--prefix=/usr/local --enable-languages=c,c++ --enable-multilib --disable-libssp
--without-headers --disable-nls --disable-werror --enable-lto --with-newlib
--with-gnu-as --with-gnu-ld --with-system-zlib
Thread model: single
gcc version 4.6.1 20110527 (prerelease) (GCC)