This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/50060] intrinsics not folded by the middle-end


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

--- Comment #11 from Paul A. Bristow <pbristow at hetp dot u-net.com> ---
Thanks for all this, which looks helpful, but I am not able to use unreleased
compiler versions, so meanwhile I am working to use a workaround (to allow me
to see what other pitfalls lie ahead for the novice ;-).  FWIW my proof of
concept is 

// Version that returns both mantissa and exponent as a tuple.
// Proof of concept only, ignoring sign, overflow, denorm, infinite and NaNs.
constexpr std::tuple<float, int> frexp(float f)
{
  int e = 0;

  if (f >= 1.f)
  {
    f /= 2 ;
    e++;
  }
  else if (f <= 0.1f)
  {
    f *= 2;
    e--;
  }
  return  std::make_tuple(f, e);
 }

allowing

constexpr std::tuple<float, int> ee = frexp(1.f);

(I can confirm by checking that debugging will not step into the function, and
also I can assign the tuple or the elements to a constexpr variable.)

Of course, this isn't a 'drop-in' for std::frexp, nor templated on other
floating-point types, like Boost.Multiprecision types, but it will help for
now.

I hope that this can be resolved somehow eventually, though I fear the pointer
update will always be a nono for constexpr, preventing a truely 'drop-in'
solution thus preventing any function that uses frexp from being constexpr.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]