Skip to content

[libc][math] Fix some mis-optimization issue with hypotf16. #141960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libc/src/math/generic/hypotf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ LLVM_LIBC_FUNCTION(float16, hypotf16, (float16 x, float16 y)) {
return a_bits.get_val();
}

// TODO: Investigate why replacing the return line below with:
// return x_bits.get_val() + y_bits.get_val();
// fails the hypotf16 smoke tests.
if (LIBC_UNLIKELY(a_u - b_u >=
static_cast<uint16_t>((FPBits::FRACTION_LEN + 2)
<< FPBits::FRACTION_LEN)))
return x_abs.get_val() + y_abs.get_val();
return a_bits.get_val() + b_bits.get_val();

float af = fputil::cast<float>(a_bits.get_val());
float bf = fputil::cast<float>(b_bits.get_val());
Expand Down
Loading