llvm/llvm-project

basic properties of floor and ceiling function

Open

#76.438 geöffnet am 27. Dez. 2023

Auf GitHub ansehen
 (12 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
floating-pointgood first issuellvm:optimizationsmissed-optimization

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

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);
}

Contributor Guide