Skip to content

log1p(x), logb(x), ilogb(x) are not folded at the compilation time when x is constant #101873

Closed
@k-arrows

Description

@k-arrows

Consider the following C++ example. The functions log2(x), log10(x) and log(x) are folded, but log1p(x), logb(x), ilogb(x) are not.
https://godbolt.org/z/nzrncEE37

#include <cmath>

double f1() {
  double num = 8.0;
  return std::log2(num);
}

double f2() {
  double num = 100.0;
  return std::log10(num);
}

double f3() {
  double num = 2.718281828459045;
  return std::log(num);
}

double f4() {
  double num = 2.718281828459045;
  return std::log1p(num - 1);
}

double f5() {
  double num = 48.0;
  return std::logb(num);
}

int f6() {
  double num = 48.0;
  return std::ilogb(num);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions