Fix for GCC Bugzilla Bug 36133

Gunnar Von Boehn gunnar@genesi-usa.com
Fri Jun 6 13:33:00 GMT 2008


Hi,

I'm hereby emailing you again, the test case and patch that are
included to the GCC bugtracker of Bug 36133.


Problem desciption:
---------------------------
GCC 68k/Coldfire backends creates unnecessary TST instructions.
On the 68k/Coldfire many instructions do set the Condition Codes automaticly.
GCC is not aware of this and GCC creates unneeded TST instructions to
create these conditions code again.


Fix:
----
Add instrutcition definitions to machine description to inform GCC
about the instructions setting the conditions codes.


How to reproduce:
-------------------------
Compile this example function withand look at the produces ASM code.
m68k-linux-gnu-gcc -mcpu=54455 -o example -Os -fomit-frame-pointer example.c
void * copy_32x4a(void *destparam, const void *srcparam, size_t size)
{
       int *dest = destparam;
       const int *src = srcparam;
       int size32;
       size32 = size / 16;
       for (; size32; size32--) {
               *dest++ = *src++;
               *dest++ = *src++;
               *dest++ = *src++;
               *dest++ = *src++;
       }
}

Look at the code and see that GCC is not aware that LSRL and the SUBQL
do both set the condition codes already, there is no need for using an
extra TST instruction at all.

Please apply the patch and recompile.
GCC is now aware that the LSR instruction does set the CC already and
will not create the unneeded TST.

Please mind that the attached patch will fix only the SHIFT instruction.
Can you use this example for the other 68K instructions, or shall I
help with this?


Kind regards

Gunnar von Boehn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GCC36133.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080606/9f9ffd64/attachment.bin>


More information about the Gcc-patches mailing list