public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/21137] Convert (a >> 2) & 1 != 0 into a & 4 != 0
[not found] <bug-21137-4@http.gcc.gnu.org/bugzilla/>
@ 2020-08-25 9:52 ` cvs-commit at gcc dot gnu.org
2022-08-09 17:57 ` cvs-commit at gcc dot gnu.org
2022-08-13 14:03 ` roger at nextmovesoftware dot com
2 siblings, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25 9:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21137
--- Comment #12 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:a0b4e42af26a85da2698e573ac8e32fa0a5709d6
commit r11-2836-ga0b4e42af26a85da2698e573ac8e32fa0a5709d6
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Tue Aug 25 10:50:48 2020 +0100
middle-end: PR tree-optimization/21137: STRIP_NOPS avoids missed
optimization.
PR tree-optimization/21137 is now an old enhancement request pointing out
that an optimization I added back in 2006, to optimize "((x>>31)&64) != 0"
as "x < 0", doesn't fire in the presence of unanticipated type conversions.
The fix is to call STRIP_NOPS at the appropriate point.
2020-08-25 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/21137
* fold-const.c (fold_binary_loc) [NE_EXPR/EQ_EXPR]: Call
STRIP_NOPS when checking whether to simplify ((x>>C1)&C2) != 0.
gcc/testsuite/ChangeLog
PR tree-optimization/21137
* gcc.dg/pr21137.c: New test.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/21137] Convert (a >> 2) & 1 != 0 into a & 4 != 0
[not found] <bug-21137-4@http.gcc.gnu.org/bugzilla/>
2020-08-25 9:52 ` [Bug tree-optimization/21137] Convert (a >> 2) & 1 != 0 into a & 4 != 0 cvs-commit at gcc dot gnu.org
@ 2022-08-09 17:57 ` cvs-commit at gcc dot gnu.org
2022-08-13 14:03 ` roger at nextmovesoftware dot com
2 siblings, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-09 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21137
--- Comment #13 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:6fc14f1963dfefead588a4cd8902d641ed69255c
commit r13-2005-g6fc14f1963dfefead588a4cd8902d641ed69255c
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Tue Aug 9 18:54:43 2022 +0100
middle-end: Optimize ((X >> C1) & C2) != C3 for more cases.
Following my middle-end patch for PR tree-optimization/94026, I'd promised
Jeff Law that I'd clean up the dead-code in fold-const.cc now that these
optimizations are handled in match.pd. Alas, I discovered things aren't
quite that simple, as the transformations I'd added avoided cases where
C2 overlapped with the new bits introduced by the shift, but the original
code handled any value of C2 provided that it had a single-bit set (under
the condition that C3 was always zero).
This patch upgrades the transformations supported by match.pd to cover
any values of C2 and C3, provided that C1 is a valid bit shift constant,
for all three shift types (logical right, arithmetic right and left).
This then makes the code in fold-const.cc fully redundant, and adds
support for some new (corner) cases not previously handled. If the
constant C1 is valid for the type's precision, the shift is now always
eliminated (with C2 and C3 possibly updated to test the sign bit).
Interestingly, the fold-const.cc code that I'm now deleting was originally
added by me back in 2006 to resolve PR middle-end/21137. I've confirmed
that those testcase(s) remain resolved with this patch (and I'll close
21137 in Bugzilla). This patch also implements most (but not all) of the
examples mentioned in PR tree-optimization/98954, for which I have some
follow-up patches.
2022-08-09 Roger Sayle <roger@nextmovesoftware.com>
Richard Biener <rguenther@suse.de>
gcc/ChangeLog
PR middle-end/21137
PR tree-optimization/98954
* fold-const.cc (fold_binary_loc): Remove optimizations to
optimize ((X >> C1) & C2) ==/!= 0.
* match.pd (cmp (bit_and (lshift @0 @1) @2) @3): Remove wi::ctz
check, and handle all values of INTEGER_CSTs @2 and @3.
(cmp (bit_and (rshift @0 @1) @2) @3): Likewise, remove wi::clz
checks, and handle all values of INTEGER_CSTs @2 and @3.
gcc/testsuite/ChangeLog
PR middle-end/21137
PR tree-optimization/98954
* gcc.dg/fold-eqandshift-4.c: New test case.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/21137] Convert (a >> 2) & 1 != 0 into a & 4 != 0
[not found] <bug-21137-4@http.gcc.gnu.org/bugzilla/>
2020-08-25 9:52 ` [Bug tree-optimization/21137] Convert (a >> 2) & 1 != 0 into a & 4 != 0 cvs-commit at gcc dot gnu.org
2022-08-09 17:57 ` cvs-commit at gcc dot gnu.org
@ 2022-08-13 14:03 ` roger at nextmovesoftware dot com
2 siblings, 0 replies; 3+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-08-13 14:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21137
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Target Milestone|--- |13.0
Resolution|--- |FIXED
CC| |roger at nextmovesoftware dot com
--- Comment #14 from Roger Sayle <roger at nextmovesoftware dot com> ---
This is currently fixed (in match.pd).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-13 14:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-21137-4@http.gcc.gnu.org/bugzilla/>
2020-08-25 9:52 ` [Bug tree-optimization/21137] Convert (a >> 2) & 1 != 0 into a & 4 != 0 cvs-commit at gcc dot gnu.org
2022-08-09 17:57 ` cvs-commit at gcc dot gnu.org
2022-08-13 14:03 ` 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).