llvm/llvm-project

basic properties of floor and ceiling function

Aperta

#76.438 aperta il 27 dic 2023

 (12 commenti) (0 reazioni) (1 assegnatario)C++ (10.782 fork)batch import
floating-pointgood first issuellvm:optimizationsmissed-optimization

Metriche repository

Star
 (26.378 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

There are other formulas that hold, but I'll list the basic ones. https://alive2.llvm.org/ce/z/dQgZ84

If I understand correctly, these transformations require nnan flag.

Original functions:

#include <cmath>

bool src1(float x)
{
  return std::floor(x) <= x;
}

bool src2(float x)
{
  return x <= std::ceil(x);
}

bool src3(float x)
{
  return std::ceil(x) == -std::floor(-x);
}

bool src4(float x)
{
  return std::floor(x) == -std::ceil(-x);
}

Guida contributor