January 24, 2014 Re: -O2/-O3 Optimization bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | On Thursday, 23 January 2014 at 16:56:19 UTC, Johannes Pfau wrote:
> I think what could be happening here is that GCC doesn't know what
> memory you're accessing via the message pointer in SendCommand.
>
> See http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
> and search for "If your assembler instructions access memory in an
> unpredictable fashion"
>
> Maybe typing "message" as uint* or uint[3]* instead of void* is already
> good enough. Otherwise try using a memory input as described on that
> page.
That appears to be it. I added memory to the clobber list and it worked without any extra modifiers. And, my executable is now only 56 bytes. It still doesn't do anything useful, but it's small and optimized :-)
Thanks so much for the information and the help.
Mike
|
January 24, 2014 Re: -O2/-O3 Optimization bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | Am Fri, 24 Jan 2014 11:12:36 +0000
schrieb "Mike" <none@none.com>:
> That appears to be it. I added memory to the clobber list and it worked without any extra modifiers. And, my executable is now only 56 bytes. It still doesn't do anything useful, but it's small and optimized :-)
>
> Thanks so much for the information and the help.
>
You're welcome!
BTW: The optimizer generated this code for SendCommand
mov r3, r0 @ command, command
mov r2, r1 @ message, message
mov r0, r3; @ command
mov r1, r2; @ message
It's a little bit unfortunate that you can't specify in extended inline
asm that you want a specific register on ARM (on x86 you could tell gcc
to use e.g. eax for this variable). Otherwise you could use something
like
asm
{
"bkpt #0xAB"
:
: [cmd] "r0" command, [msg] "r1" message
: ;
};
and the compiler could avoid those useless moves.
|
Copyright © 1999-2021 by the D Language Foundation