public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables
@ 2020-08-18 16:36 gabravier at gmail dot com
2020-08-25 10:47 ` [Bug tree-optimization/96681] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gabravier at gmail dot com @ 2020-08-18 16:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
Bug ID: 96681
Summary: Failure to optimize xor of comparisons with specific
constants to comparison of xor-ed of compared
variables
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int f(int x, int y)
{
return (x < 0) ^ (y < 0);
}
This can be optimized to `return (x ^ y) < 0;`. LLVM does this transformation,
but GCC does not. This transformation can also be done with `return (x > -1) ^
(y > -1);`. There is also a similar transformation with `return (x > -1) ^ (y <
0);`, which can be optimized to `return ~(x ^ y) < 0;`.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/96681] Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables
2020-08-18 16:36 [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables gabravier at gmail dot com
@ 2020-08-25 10:47 ` rguenth at gcc dot gnu.org
2021-01-15 13:22 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 10:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-08-25
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/96681] Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables
2020-08-18 16:36 [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables gabravier at gmail dot com
2020-08-25 10:47 ` [Bug tree-optimization/96681] " rguenth at gcc dot gnu.org
@ 2021-01-15 13:22 ` jakub at gcc dot gnu.org
2021-01-15 20:11 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-15 13:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49972
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49972&action=edit
gcc11-pr96681.patch
Untested fix.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/96681] Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables
2020-08-18 16:36 [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables gabravier at gmail dot com
2020-08-25 10:47 ` [Bug tree-optimization/96681] " rguenth at gcc dot gnu.org
2021-01-15 13:22 ` jakub at gcc dot gnu.org
@ 2021-01-15 20:11 ` cvs-commit at gcc dot gnu.org
2021-01-15 20:14 ` jakub at gcc dot gnu.org
2022-11-28 22:42 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-15 20:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:5c046034e3ea61dd68965154a398f8f813daf8f2
commit r11-6738-g5c046034e3ea61dd68965154a398f8f813daf8f2
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jan 15 21:10:44 2021 +0100
match.pd: Optimize (x < 0) ^ (y < 0) to (x ^ y) < 0 etc. [PR96681]
This patch simplifies comparisons that test the sign bit xored together.
If the comparisons are both < 0 or both >= 0, then we should xor the
operands
together and compare the result to < 0, if the comparisons are different,
we should compare to >= 0.
2021-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96681
* match.pd ((x < 0) ^ (y < 0) to (x ^ y) < 0): New simplification.
((x >= 0) ^ (y >= 0) to (x ^ y) < 0): Likewise.
((x < 0) ^ (y >= 0) to (x ^ y) >= 0): Likewise.
((x >= 0) ^ (y < 0) to (x ^ y) >= 0): Likewise.
* gcc.dg/tree-ssa/pr96681.c: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/96681] Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables
2020-08-18 16:36 [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables gabravier at gmail dot com
` (2 preceding siblings ...)
2021-01-15 20:11 ` cvs-commit at gcc dot gnu.org
@ 2021-01-15 20:14 ` jakub at gcc dot gnu.org
2022-11-28 22:42 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-15 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/96681] Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables
2020-08-18 16:36 [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables gabravier at gmail dot com
` (3 preceding siblings ...)
2021-01-15 20:14 ` jakub at gcc dot gnu.org
@ 2022-11-28 22:42 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96681
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-28 22:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 16:36 [Bug tree-optimization/96681] New: Failure to optimize xor of comparisons with specific constants to comparison of xor-ed of compared variables gabravier at gmail dot com
2020-08-25 10:47 ` [Bug tree-optimization/96681] " rguenth at gcc dot gnu.org
2021-01-15 13:22 ` jakub at gcc dot gnu.org
2021-01-15 20:11 ` cvs-commit at gcc dot gnu.org
2021-01-15 20:14 ` jakub at gcc dot gnu.org
2022-11-28 22:42 ` 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).