public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift @ 2023-03-06 9:55 crazylht at gmail dot com 2023-03-06 17:46 ` [Bug middle-end/109038] " pinskia at gcc dot gnu.org 2023-05-19 23:29 ` [Bug tree-optimization/109038] " pinskia at gcc dot gnu.org 0 siblings, 2 replies; 3+ messages in thread From: crazylht at gmail dot com @ 2023-03-06 9:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109038 Bug ID: 109038 Summary: Miss optimization to simplify bit_and + rotate to shift Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- Target: x86_64-*-* i?86-*-* unsigned foo (unsigned int a) { unsigned int b = a & 0x00FFFFFF; unsigned int c = ((b & 0x000000FF) << 8 | (b & 0x0000FF00) << 8 | (b & 0x00FF0000) << 8 | (b & 0xFF000000) >> 24); return c; } gcc generates foo: mov eax, edi and eax, 16777215 rol eax, 8 ret But it can be optimized as below foo: # @foo mov eax, edi shl eax, 8 ret ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/109038] Miss optimization to simplify bit_and + rotate to shift 2023-03-06 9:55 [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift crazylht at gmail dot com @ 2023-03-06 17:46 ` pinskia at gcc dot gnu.org 2023-05-19 23:29 ` [Bug tree-optimization/109038] " pinskia at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-06 17:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109038 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 109037 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/109038] Miss optimization to simplify bit_and + rotate to shift 2023-03-06 9:55 [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift crazylht at gmail dot com 2023-03-06 17:46 ` [Bug middle-end/109038] " pinskia at gcc dot gnu.org @ 2023-05-19 23:29 ` pinskia at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-05-19 23:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109038 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Status|UNCONFIRMED |NEW Last reconfirmed| |2023-05-19 Ever confirmed|0 |1 Component|middle-end |tree-optimization --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. (simplify (rrotate (bit_and @0 INTEGER_CST@1) INTEGER_CST@2) (if (@1 == (type)(~0) >> (typebits-@2)) (lshift @0 { typebits - @2; })) (simplify (lrotate (bit_and @0 INTEGER_CST@1) INTEGER_CST@2) (if (@1 == (type)(~0) >> (@2)) (lshift @0 { @2; })) There could be more dealing with the result being logical shift right. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-19 23:29 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-06 9:55 [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift crazylht at gmail dot com 2023-03-06 17:46 ` [Bug middle-end/109038] " pinskia at gcc dot gnu.org 2023-05-19 23:29 ` [Bug tree-optimization/109038] " 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).