public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/104375] New: [x86] Failure to recognize bzhi patter nwhen shr is present
@ 2022-02-03 23:17 gabravier at gmail dot com
  2022-02-04  0:00 ` [Bug target/104375] [x86] Failure to recognize bzhi pattern when " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gabravier at gmail dot com @ 2022-02-03 23:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104375

            Bug ID: 104375
           Summary: [x86] Failure to recognize bzhi patter nwhen shr is
                    present
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

#include <stdint.h>

uint64_t bextr_u64(uint64_t w, unsigned off, unsigned int len)
{
        return (w >> off) & ((1U << len) - 1U);
}

With -mbmi2, this can be optimized to using shrx followed by bzhi. This
transformation is done by LLVM, but not by GCC.


PS: Even in the case where the shr is removed and thus the bzhi pattern is
recognized (e.g. `return w & ((1U << len) - 1U);`), it is still not compiled
optimally as it for some reason decides to put the result of the bzhi in an
intermediary register before moving it to eax.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-18 17:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 23:17 [Bug target/104375] New: [x86] Failure to recognize bzhi patter nwhen shr is present gabravier at gmail dot com
2022-02-04  0:00 ` [Bug target/104375] [x86] Failure to recognize bzhi pattern when " pinskia at gcc dot gnu.org
2022-04-28  7:09 ` crazylht at gmail dot com
2022-05-18  2:58 ` cvs-commit at gcc dot gnu.org
2022-05-18  2:59 ` crazylht at gmail dot com
2023-02-18 13:58 ` gabravier at gmail dot com
2023-02-18 17:08 ` ubizjak at gmail 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).