public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96928] New: Failure to optimize one's complement abs pattern
@ 2020-09-03 18:25 gabravier at gmail dot com
2021-01-04 14:55 ` [Bug tree-optimization/96928] " jakub at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: gabravier at gmail dot com @ 2020-09-03 18:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96928
Bug ID: 96928
Summary: Failure to optimize one's complement abs pattern
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 a)
{
return (a < 0) ? ~a : a;
}
This can be optimized to `return (a >> 31) ^ a;`. This transformation is done
by LLVM, but not by GCC.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/96928] Failure to optimize one's complement abs pattern
2020-09-03 18:25 [Bug tree-optimization/96928] New: Failure to optimize one's complement abs pattern gabravier at gmail dot com
@ 2021-01-04 14:55 ` jakub at gcc dot gnu.org
2021-01-05 15:36 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-04 14:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96928
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-01-04
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49874
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49874&action=edit
gcc11-pr96928.patch
Untested fix.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/96928] Failure to optimize one's complement abs pattern
2020-09-03 18:25 [Bug tree-optimization/96928] New: Failure to optimize one's complement abs pattern gabravier at gmail dot com
2021-01-04 14:55 ` [Bug tree-optimization/96928] " jakub at gcc dot gnu.org
@ 2021-01-05 15:36 ` cvs-commit at gcc dot gnu.org
2021-01-05 15:37 ` jakub at gcc dot gnu.org
2021-05-16 22:10 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-05 15:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96928
--- 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:576714b309b330df0e80e34114bcdf0bba35e146
commit r11-6472-g576714b309b330df0e80e34114bcdf0bba35e146
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Jan 5 16:35:22 2021 +0100
phiopt: Optimize x < 0 ? ~y : y to (x >> 31) ^ y [PR96928]
As requested in the PR, the one's complement abs can be done more
efficiently without cmov or branching.
Had to change the ifcvt-onecmpl-abs-1.c testcase, we no longer optimize
it in ifcvt, on x86_64 with -m32 we generate in the end the exact same
code, but with -m64:
movl %edi, %eax
- notl %eax
- cmpl %edi, %eax
- cmovl %edi, %eax
+ sarl $31, %eax
+ xorl %edi, %eax
ret
2021-01-05 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96928
* tree-ssa-phiopt.c (xor_replacement): New function.
(tree_ssa_phiopt_worker): Call it.
* gcc.dg/tree-ssa/pr96928.c: New test.
* gcc.target/i386/ifcvt-onecmpl-abs-1.c: Remove -fdump-rtl-ce1,
instead of scanning rtl dump for ifcvt message check assembly
for xor instruction.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/96928] Failure to optimize one's complement abs pattern
2020-09-03 18:25 [Bug tree-optimization/96928] New: Failure to optimize one's complement abs pattern gabravier at gmail dot com
2021-01-04 14:55 ` [Bug tree-optimization/96928] " jakub at gcc dot gnu.org
2021-01-05 15:36 ` cvs-commit at gcc dot gnu.org
@ 2021-01-05 15:37 ` jakub at gcc dot gnu.org
2021-05-16 22:10 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-05 15:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96928
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] 5+ messages in thread
* [Bug tree-optimization/96928] Failure to optimize one's complement abs pattern
2020-09-03 18:25 [Bug tree-optimization/96928] New: Failure to optimize one's complement abs pattern gabravier at gmail dot com
` (2 preceding siblings ...)
2021-01-05 15:37 ` jakub at gcc dot gnu.org
@ 2021-05-16 22:10 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-16 22:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96928
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note while moving this optimization to match-and-simplify I noticed that the
gimple produced is:
(~a) ^ b
But this get changed around to:
~(a ^ b)
By PRE latter on.
I only noticed this because the testcase is failing as it depends being that.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-16 22:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 18:25 [Bug tree-optimization/96928] New: Failure to optimize one's complement abs pattern gabravier at gmail dot com
2021-01-04 14:55 ` [Bug tree-optimization/96928] " jakub at gcc dot gnu.org
2021-01-05 15:36 ` cvs-commit at gcc dot gnu.org
2021-01-05 15:37 ` jakub at gcc dot gnu.org
2021-05-16 22:10 ` 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).