[PATCH] D128591: Transforms: refactor pow(x, n) expansion where n is a constant integer value
eaeltsin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 04:53:56 PDT 2022
eaeltsin added a comment.
Hi,
This patch introduces the difference between new inlined and library versions of `std::pow`, at least on `x86_64`. For large exponents, the difference is large. Also, when the difference accumulates, it makes a lot of existing tests that compare against golden values to go far beyond the meaningful margin.
Similarly, it introduces the difference between `pow` of constant and `pow` of non-constant with the same value.
I think such differences make related debugging a lot more complex. What do you think?
Here are the tests:
[[clang::optnone]] double test_pow(double x, double y) {
return std::pow(x, y);
}
// PASS - compiler evaluates std::pow(const, const) similar to the library?
TEST(Test, Pow_const) {
double x = 8.804009981602594;
double y = 10.0;
double t = test_pow(x, y);
double z = std::pow(x, y);
EXPECT_TRUE(t - z < 1e-6 && z -t < 1e-6);
}
[[clang::optnone]] double init(const char* buf) {
double x;
memcpy(&x, buf, sizeof(double));
return x;
}
// FAIL - https://reviews.llvm.org/D128591 introduces difference.
TEST(Test, Pow_nonconst) {
double x = init("\x0a\x48\x41\x32\xa7\x9b\x21\x40"); // 8.804009981602594
double y = 10.0;
double t = test_pow(x, y);
double z = std::pow(x, y);
EXPECT_TRUE(t - z < 1e-6 && z -t < 1e-6);
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128591/new/
https://reviews.llvm.org/D128591
More information about the llvm-commits
mailing list