[llvm-bugs] [Bug 45361] New: fold away float to double (to float) conversion in copysign

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 30 09:16:32 PDT 2020


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

            Bug ID: 45361
           Summary: fold away float to double (to float) conversion in
                    copysign
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nok.raven at gmail.com
                CC: llvm-bugs at lists.llvm.org

#include <cmath>

float foo(float x, float y)
{
    return std::copysign(x, y);
}
// bug 45305-like foldable float to double promotion
float bar(float x, float y)
{
    return std::copysign(x, double(y));
}
// previous + fext-ftrunc pair across copysign
float qaz(float x, float y)
{
    return std::copysign(double(x), y);
}

define float @foo(float %0, float %1) {
  %3 = tail call float @llvm.copysign.f32(float %0, float %1) #2
  ret float %3
}

define float @bar(float %0, float %1) {
  %3 = fpext float %1 to double
  %4 = fpext float %0 to double
  %5 = tail call double @llvm.copysign.f64(double %4, double %3) #2
  %6 = fptrunc double %5 to float
  ret float %6
}

define float @qaz(float %0, float %1) {
  %3 = fpext float %0 to double
  %4 = fpext float %1 to double
  %5 = tail call double @llvm.copysign.f64(double %3, double %4) #2
  %6 = fptrunc double %5 to float
  ret float %6
}

https://godbolt.org/z/sKIjDg

-- 
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/20200330/324a1000/attachment-0001.html>


More information about the llvm-bugs mailing list