* Optimizer failure
@ 2021-08-07 11:57 Stefan Kanthak
0 siblings, 0 replies; only message in thread
From: Stefan Kanthak @ 2021-08-07 11:57 UTC (permalink / raw)
To: GCC Development
Hi,
for the function (really: ternary expressions)
int dummy(int x)
{
#ifdef VARIANT
x < 0 ? --x : x > 0 ? ++x : 0;
#else
x < 0 ? --x : x > 0 ? ++x : x;
#endif
}
GCC 10.2.0 generates the following code targeting AMD64:
testl %edi, %edi
js .L0
leal 1(%rdi), %eax
movl $0, %edi # SUPERFLUOUS:
cmove %edi, %eax # cmove is only executed if edi was already 0
ret
.L0:
leal -1(%rdi), %eax
ret
Targeting i386, GCC 10.2.0 generates it the other way 'round:
movl 4(%esp), %eax
testl %eax, %eax
js L0
leal 1(%eax), %edx
movl $0, %eax # SUPERFLUOUS:
cmovne %edx, %eax # cmovne is only executed if eax was not 0
ret
L0:
subl $1, %eax
ret
regards
Stefan
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-07 12:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-07 11:57 Optimizer failure Stefan Kanthak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).