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

            Bug ID: 93039
           Summary: Fails to use SSE bitwise ops for float-as-int
                    manipulations
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

(the non-regression part of PR 92905)

libm functions need to manipulate individual bits of float/double
representations with good efficiency, but on x86 gcc typically does them on
gprs even when it results in sse-gpreg-sse move chain:

float foo(float x)
{
    union {float f; unsigned i;} u = {x};
    u.i &= ~0x80000000;
    return u.f;
}

foo:
        movd    eax, xmm0
        and     eax, 2147483647
        movd    xmm0, eax
        ret

It's good to use bitwise ops on general registers if the source or destination
needs to be in a general registe, but for cases like the above creating a
roundtrip is not desirable.

(GCC gets this example right on aarch64; LLVM on x86 compiles this to SSE/AVX
bitwise 'and', taking the immediate from memory)

Reply via email to