[llvm-bugs] [Bug 49161] New: Failure to optimize comparison of float with itself when it's converted to double and -ftrapping-math is on

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 12 08:48:31 PST 2021


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

            Bug ID: 49161
           Summary: Failure to optimize comparison of float with itself
                    when it's converted to double and -ftrapping-math is
                    on
           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

bool f(float x)
{
    return x == (float)(double)x;
}

This can be optimized with `return x == x;`, even with `-ftrapping-math` (at
least according to GCC). This transformation is done by GCC, but not by LLVM.

Godbolt comparison: https://godbolt.org/z/TdozY4
(if someone knows how to do alive2 checks for stuff that involves floating
point comparisons, I would be glad to know)

-- 
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/20210212/9508d5a9/attachment.html>


More information about the llvm-bugs mailing list