https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95921

            Bug ID: 95921
           Summary: [m68k] invalid codegen for __builtin_sqrt
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx
  Target Milestone: ---

On ISA levels below 68040, __builtin_sqrt expands to code that performs an
extended-precision sqrt operation rather than a double-precision one. Not only
does this give the wrong result; it enables further cascadingly-wrong
optimization ala #93806 and related bugs, because the compiler thinks the value
in the output register is a double, but it's not.

I think the right fix is making the rtl in m68k.md only allow long double
operands unless ISA level is at least 68040, in which case the
correctly-rounding instruction can be used. Then the standard function will be
used instead of a builtin definition, and it can patch up the result
accordingly.

Reply via email to