[llvm-bugs] [Bug 49822] New: Missed fold for copysign on integers

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 2 15:19:15 PDT 2021


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

            Bug ID: 49822
           Summary: Missed fold for copysign on integers
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: rifkin at purdue.edu
                CC: llvm-bugs at lists.llvm.org

C++ has no std::sign function. std::copysign may be used for this functionality
with a call along the lines of: std::copysign(1, n).
When std::copysign is provided with an integer argument and the return value is
immediately cast to an integer, the copysign call can be folded away in favor
of an icmp/select pattern along the lines of that produced for (n < 0 ? -1 :
1).
Currently, the generated assembly for copysign includes an int -> float
conversion followed shortly by a float -> int conversion.
https://godbolt.org/z/MoPr9javo

-- 
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/20210402/3f044693/attachment.html>


More information about the llvm-bugs mailing list