[llvm-bugs] [Bug 45480] New: clang fails to recognize popcount corresponding as best as possible to detectPopcountIdiom example

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 8 17:31:42 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45480

            Bug ID: 45480
           Summary: clang fails to recognize popcount corresponding as
                    best as possible to detectPopcountIdiom example
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23335
  --> https://bugs.llvm.org/attachment.cgi?id=23335&action=edit
Contains relevant .{S,bc} files from both gcc and clang along with C source
code

I found the code at
https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/Transforms/Scalar/LoopIdiomRecognize.cpp#L1260-L1283
interesting and wanted to reproduce an example of what LLVM reproduces at the
most very basic level. LLVM, however, fails to optimize such a reproduction to
an `llvm.ctpop` call. 
GCC, however, manages to optimize it properly to a `__builtin_popcount` call
internally.

See https://godbolt.org/z/Sge8tQ for a direct comparison, I have also added an
attachment archive with relevant source/assembly/bytecode files.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200409/cf7889f6/attachment.html>


More information about the llvm-bugs mailing list