This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
m68k: testing shift result
- From: Alex <cirrus75 at uol dot com dot br>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 17 May 2009 09:32:20 -0300
- Subject: m68k: testing shift result
Hi,
If I compile the following code for coldfire:
int foo(int a)
{
if(a >> 3)
return 10;
else
return 100;
}
the output with -O2 or -O3 optimization is:
00000000 <foo>:
0: 4e56 0000 linkw %fp,#0
4: 202e 0008 movel %fp@(8),%d0
8: e680 asrl #3,%d0
a: 4a80 tstl %d0
c: 6608 bnes 16 <foo+0x16>
e: 4e5e unlk %fp
10: 103c 0064 moveb #100,%d0
14: 4e75 rts
16: 4e5e unlk %fp
18: 700a moveq #10,%d0
1a: 4e75 rts
In Coldfire RM it says that zero flag is set by asrl if the result is 0,
so "tstl %d0" is not necessary, right ?
In 68020 the result is the same, but I could not find the 680x0 RM manual.
thank you,
Alex Prado