llvm/llvm-project

basic properties of floor and ceiling function

開放

#76,438 建立於 2023年12月27日

 (12 則留言) (0 個反應) (1 位負責人)C++ (10,782 個分叉)batch import
floating-pointgood first issuellvm:optimizationsmissed-optimization

倉庫指標

星標
 (26,378 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南