public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/38126] suboptimal code for (a && b || !a && !b)
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
@ 2012-02-01 22:38 ` pinskia at gcc dot gnu.org
2012-02-02 5:26 ` svfuerst at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-01 22:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-02-01
Ever Confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-01 22:37:56 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/38126] suboptimal code for (a && b || !a && !b)
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
2012-02-01 22:38 ` [Bug middle-end/38126] suboptimal code for (a && b || !a && !b) pinskia at gcc dot gnu.org
@ 2012-02-02 5:26 ` svfuerst at gmail dot com
2012-02-02 6:12 ` svfuerst at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: svfuerst at gmail dot com @ 2012-02-02 5:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126
Steven Fuerst <svfuerst at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |svfuerst at gmail dot com
--- Comment #3 from Steven Fuerst <svfuerst at gmail dot com> 2012-02-02 05:25:34 UTC ---
For the first pair of functions, this is even faster:
neg %rdi
sbb %eax, %eax
neg %rsi
adc $1, %eax
and $1, %eax
retq
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/38126] suboptimal code for (a && b || !a && !b)
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
2012-02-01 22:38 ` [Bug middle-end/38126] suboptimal code for (a && b || !a && !b) pinskia at gcc dot gnu.org
2012-02-02 5:26 ` svfuerst at gmail dot com
@ 2012-02-02 6:12 ` svfuerst at gmail dot com
2021-06-03 2:48 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: svfuerst at gmail dot com @ 2012-02-02 6:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126
--- Comment #4 from Steven Fuerst <svfuerst at gmail dot com> 2012-02-02 06:11:27 UTC ---
Two more cases for simple boolean logic optimizations.
gcc-4.7 produces with -O3 for
int test_and(long long x, long long y)
{
return x && y;
}
test %rsi, %rsi
setne %dl
xor %eax, %eax
test %rdi, %rdi
setne %al
and %edx, %eax
retq
Whereas this is faster:
neg %rdi
sbb %rdi, %rdi
xor %eax, %eax
and %rsi, %rdi
setne %al
retq
Also
int test_other(long long x, long long y)
{
return !x && y; /* or !(x || !y) */
}
gives
test %rsi,%rsi
setne %dl
xor %eax,%eax
test %rdi,%rdi
sete %al
and %edx,%eax
retq
when
sub $1, %rsi
sbb %rsi, %rsi
xor %eax, %eax
or %rdi, %rsi
sete %al
retq
is faster.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/38126] suboptimal code for (a && b || !a && !b)
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2012-02-02 6:12 ` svfuerst at gmail dot com
@ 2021-06-03 2:48 ` pinskia at gcc dot gnu.org
2022-11-26 20:40 ` [Bug target/38126] " pinskia at gcc dot gnu.org
2022-12-19 20:57 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-03 2:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For the original testcase with GCC 7, we get the same(similar enough) code gen
for both functions now.
foo:
.LFB0:
.cfi_startproc
testq %rdi, %rdi
setne %al
testq %rsi, %rsi
sete %dl
xorl %edx, %eax
movzbl %al, %eax
ret
bar:
.LFB1:
.cfi_startproc
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
setne %dl
xorl %edx, %eax
movzbl %al, %eax
ret
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/38126] suboptimal code for (a && b || !a && !b)
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-06-03 2:48 ` pinskia at gcc dot gnu.org
@ 2022-11-26 20:40 ` pinskia at gcc dot gnu.org
2022-12-19 20:57 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-26 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64
Component|middle-end |target
Target Milestone|--- |13.0
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #1)
> Code involving bool variables is similarly suboptimal:
The bool part was fixed for GCC 13 by r13-1779-g375668e0508fbe .
The rest is a target issue dealing with using sbb more.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/38126] suboptimal code for (a && b || !a && !b)
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2022-11-26 20:40 ` [Bug target/38126] " pinskia at gcc dot gnu.org
@ 2022-12-19 20:57 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-19 20:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.0 |---
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-19 20:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-38126-4@http.gcc.gnu.org/bugzilla/>
2012-02-01 22:38 ` [Bug middle-end/38126] suboptimal code for (a && b || !a && !b) pinskia at gcc dot gnu.org
2012-02-02 5:26 ` svfuerst at gmail dot com
2012-02-02 6:12 ` svfuerst at gmail dot com
2021-06-03 2:48 ` pinskia at gcc dot gnu.org
2022-11-26 20:40 ` [Bug target/38126] " pinskia at gcc dot gnu.org
2022-12-19 20:57 ` pinskia at gcc dot gnu.org
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).