This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: GCC-ARM optimization BUG report
- To: YoungChan Yoon <treeman at eztcp dot com>
- Subject: Re: GCC-ARM optimization BUG report
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Sun, 23 Jul 2000 14:06:33 +0100
- Cc: bug-gcc at gnu dot org
- Cc: rearnsha at arm dot com
- Organization: ARM Ltd.
- Reply-To: rearnsha at arm dot com
> Hello..
>
> I'm developing In-House RTOS using GCC-ARM.
> gcc_arm generates illegal conditional code sequence with -O option.
> original C-code and it's assembly output are followed.
>
> /* C-code */
> if(stat_func_tcp)
> ptr += stat_func_tcp(ptr);
>
> /* assembly output */
> 1 : ldrne r3, [r2, #0] /* take function address */
> 2 : movne r0, r4 /* r0 is a register arguement for pointer 'ptr' */
> 3 : movne lr, pc
> 4 : movne pc, r3 /* call stat_func_tcp() */
> 5 : addne r4, r4, r0
>
> see line 5.
> If CPSR is modified in function stat_func_tcp(),
> 'addne' refers to dirty CPSR, result in skipping add operation.
>
> No problem without optimize option.
>
> Is this a BUG?
It depends on which flags you passed to the compiler, and which
configuration for the ARM that you used.
The above code is legal when the compiler is generating code for an
ARM2/3, or when generating code for an arm6/7 that is being run in ARM3
compatibility mode (mode26).
Try adding -mapcs-32 to list of compiler flags. If this fixes the output
then you have built a 26-bit mode version of the compiler by default (you
would be best to select a configuration that builds for apcs-32 mode)