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

            Bug ID: 109028
           Summary: fcmov will not be generated
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: g.peterh...@t-online.de
  Target Milestone: ---

Hello,
very rarely fcmov instructions are generated (https://godbolt.org/z/qE6f76Gda)

thx
Gero

#include <cmath>
#include <array>
#include <numbers>

static constexpr size_t Size = 1024;

using float80_t = long double;
using float64_t = double;
using float32_t = float;

template <typename Type>
inline constexpr Type   foo(const Type x)   noexcept
{
    return (x > 42) ? std::numbers::pi_v<Type> : std::numbers::e_v<Type>;
}

template <typename Type>
inline constexpr Type   bar(const Type x)   noexcept
{
   return std::signbit(x) ? std::numbers::pi_v<Type> : 0;
}

template <typename Type>
inline constexpr Type   baz(const Type x)   noexcept
{
    return std::copysign(std::numbers::pi_v<Type>, x);
}

template <typename Container, typename Function>
inline constexpr void for_all(Container& cnt, Function&& f)     noexcept
{
    for (auto& val : cnt)
    {
        val = f(val);
    }
}

float80_t foo80(const float80_t x)   noexcept { return foo(x); }
float80_t bar80(const float80_t x)   noexcept { return bar(x); }
float80_t baz80(const float80_t x)   noexcept { return baz(x); }

void foos80(std::array<float80_t, Size>& cnt)   noexcept { for_all(cnt,
foo<float80_t>); }
void bars80(std::array<float80_t, Size>& cnt)   noexcept { for_all(cnt,
bar<float80_t>); }
void bazs80(std::array<float80_t, Size>& cnt)   noexcept { for_all(cnt,
baz<float80_t>); }

Reply via email to