public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence)
[not found] <bug-71343-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-03 19:17 ` pinskia at gcc dot gnu.org
2022-08-15 16:33 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 19:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71343
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence)
[not found] <bug-71343-4@http.gcc.gnu.org/bugzilla/>
2021-08-03 19:17 ` [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence) pinskia at gcc dot gnu.org
@ 2022-08-15 16:33 ` cvs-commit at gcc dot gnu.org
2023-01-11 16:56 ` cvs-commit at gcc dot gnu.org
2023-01-15 19:05 ` roger at nextmovesoftware dot com
3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-15 16:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71343
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:
https://gcc.gnu.org/g:03acd8b6429e22068330dce5abf129291d3f26de
commit r13-2047-g03acd8b6429e22068330dce5abf129291d3f26de
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Mon Aug 15 17:32:26 2022 +0100
PR tree-optimization/71343: Optimize (X<<C)&(Y<<C) as (X&Y)<<C.
This patch is the first part of a solution to PR tree-optimization/71343,
a missed-optimization enhancement request where GCC fails to see that
(a<<2)+(b<<2) == a*4+b*4.
This piece is that (X<<C) op (Y<<C) can be simplified to (X op Y) << C,
for many binary operators, including AND, IOR, XOR, and (if overflow
isn't an issue) PLUS and MINUS. Likewise, the right shifts (both logical
and arithmetic) and bit-wise logical operators can be simplified in a
similar fashion. These all reduce the number of GIMPLE binary operations
from 3 to 2, by combining/eliminating a shift operation.
2022-08-15 Roger Sayle <roger@nextmovesoftware.com>
Richard Biener <rguenther@suse.de>
gcc/ChangeLog
PR tree-optimization/71343
* match.pd (op (lshift @0 @1) (lshift @2 @1)): Optimize the
expression (X<<C) + (Y<<C) to (X+Y)<<C for multiple operators.
(op (rshift @0 @1) (rshift @2 @1)): Likewise, simplify
(X>>C)^(Y>>C)
to (X^Y)>>C for binary logical operators, AND, IOR and XOR.
gcc/testsuite/ChangeLog
PR tree-optimization/71343
* gcc.dg/pr71343-1.c: New test case.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence)
[not found] <bug-71343-4@http.gcc.gnu.org/bugzilla/>
2021-08-03 19:17 ` [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence) pinskia at gcc dot gnu.org
2022-08-15 16:33 ` cvs-commit at gcc dot gnu.org
@ 2023-01-11 16:56 ` cvs-commit at gcc dot gnu.org
2023-01-15 19:05 ` roger at nextmovesoftware dot com
3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-11 16:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71343
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:
https://gcc.gnu.org/g:98837d6e79dd27c15f5218f3f1ddf838cda4796c
commit r13-5111-g98837d6e79dd27c15f5218f3f1ddf838cda4796c
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Wed Jan 11 16:54:58 2023 +0000
PR tree-optimization/71343: Value number X<<2 as X*4.
This patch is the second part of a fix for PR tree-optimization/71343,
that implements Richard Biener's suggestion of using tree-ssa's value
numbering instead of match.pd. The change is that when assigning a
value number for the expression X<<C, we actually look-up or insert
the value number for the multiplication X*(1<<C). This elegantly
handles the fact that we (intentionally) don't canonicalize these as
equivalent in GIMPLE, and the optimization/equivalence in PR 71343 now
happens by (tree-ssa SCCVN) magic.
2023-01-11 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/71343
* tree-ssa-sccvn.cc (visit_nary_op) <case LSHIFT_EXPR>: Make
the value number of the expression X << C the same as the value
number for the multiplication X * (1<<C).
gcc/testsuite/ChangeLog
PR tree-optimization/71343
* gcc.dg/pr71343-2.c: New test case.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence)
[not found] <bug-71343-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2023-01-11 16:56 ` cvs-commit at gcc dot gnu.org
@ 2023-01-15 19:05 ` roger at nextmovesoftware dot com
3 siblings, 0 replies; 4+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-01-15 19:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71343
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|--- |13.0
CC| |roger at nextmovesoftware dot com
Resolution|--- |FIXED
--- Comment #5 from Roger Sayle <roger at nextmovesoftware dot com> ---
This should now be fixed on mainline.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-15 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-71343-4@http.gcc.gnu.org/bugzilla/>
2021-08-03 19:17 ` [Bug tree-optimization/71343] missed optimization (can't "prove" shift and multiplication equivalence) pinskia at gcc dot gnu.org
2022-08-15 16:33 ` cvs-commit at gcc dot gnu.org
2023-01-11 16:56 ` cvs-commit at gcc dot gnu.org
2023-01-15 19:05 ` roger at nextmovesoftware dot com
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).