llvm/llvm-project

basic properties of floor and ceiling function

Open

#76,438 创建于 2023年12月27日

在 GitHub 查看
 (12 评论) (0 反应) (1 负责人)C++ (10,782 fork)batch import
floating-pointgood first issuellvm:optimizationsmissed-optimization

仓库指标

Star
 (26,378 star)
PR 合并指标
 (平均合并 1天 2小时) (30 天内合并 1,000 个 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);
}

贡献者指南