[llvm-bugs] [Bug 48999] New: Failure to optimize combined popcount pattern

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 2 05:53:08 PST 2021


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

            Bug ID: 48999
           Summary: Failure to optimize combined popcount pattern
           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

int f(unsigned int a, unsigned int b)
{
    return __builtin_popcount(a & 8) + __builtin_popcount(b & 2);
}

This can be optimized to `return __builtin_popcount((a & 8) | (b & 2));`. This
transformation is done by GCC, but not by LLVM.

Godbolt comparison: https://godbolt.org/z/zjP3Ys
(If someone can tell me how to use ctpop in alive2 that'd be nice btw, I
couldn't get it to work personally)

-- 
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/20210202/f74a6064/attachment.html>


More information about the llvm-bugs mailing list