public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106471] New: Strange code generation for __builtin_ctzl()
@ 2022-07-28 23:37 torvalds@linux-foundation.org
  2022-07-28 23:39 ` [Bug c/106471] " torvalds@linux-foundation.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: torvalds@linux-foundation.org @ 2022-07-28 23:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106471
           Summary: Strange code generation for __builtin_ctzl()
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: torvalds@linux-foundation.org
  Target Milestone: ---

So this actually started out as a clang issue report about bad inline asm input
argument behavior at

   https://github.com/llvm/llvm-project/issues/56789

but as part of that I was looking at __builtin_ctzl() and while gcc DTRT for
the inline asm version we use in the kernel, the builtin acts very oddly
indeed.

IOW, this code:

        unsigned long test(unsigned long arg)
        {
                return __builtin_ctzl(arg);
        }

generates this odd result with 'gcc -O2 -S':

        xorl    %eax, %eax
        rep bsfq        %rdi, %rax
        cltq
        ret

where the xor and the cltq both just confuse me.

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

end of thread, other threads:[~2023-05-19  1:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 23:37 [Bug c/106471] New: Strange code generation for __builtin_ctzl() torvalds@linux-foundation.org
2022-07-28 23:39 ` [Bug c/106471] " torvalds@linux-foundation.org
2022-07-28 23:48 ` [Bug target/106471] " pinskia at gcc dot gnu.org
2022-07-28 23:56 ` pinskia at gcc dot gnu.org
2022-07-29  0:01 ` pinskia at gcc dot gnu.org
2022-07-29  0:08 ` torvalds@linux-foundation.org
2022-07-29  0:16 ` torvalds@linux-foundation.org
2022-07-29  7:58 ` rguenth at gcc dot gnu.org
2023-05-18 23:30 ` [Bug target/106471] -mpcu=generic might want to remove X86_TUNE_AVOID_FALSE_DEP_FOR_BMI now pinskia at gcc dot gnu.org
2023-05-19  1:52 ` [Bug target/106471] -march=generic " crazylht at gmail dot com
2023-05-19  1:53 ` crazylht 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).