[llvm-bugs] [Bug 48608] New: Failure to optimize popcount of a single bit

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 27 15:56:05 PST 2020


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

            Bug ID: 48608
           Summary: Failure to optimize popcount of a single bit
           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)
{
    return __builtin_popcount(a >> (__CHAR_BIT__ * sizeof(a) - 1));
}

This can be optimized to `return (a >> (__CHAR_BIT__ * sizeof(a) - 1));`. This
transformation is done by GCC, but not by LLVM.

See also comparison here : https://godbolt.org/z/1Kz5qf

-- 
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/20201227/0e855132/attachment.html>


More information about the llvm-bugs mailing list