Conversation
100c507 to
7f0c1bc
Compare
7230b09 to
d2d4f22
Compare
CI in [1] seems to indicate that there are cases where the `f16` infinite recursion bug ([2], [3]) can make its way into what gets called during tests, even though this doesn't seem to be the usual case. In order to make sure that we avoid these completely, just unset `f16_enabled` on any platforms that have the recursion problem. This also refactors the `match` statement to be more in line with `library/std/build.rs`. [1]: rust-lang#729 [2]: llvm/llvm-project#97981 [3]: rust-lang#651
1a86a8d to
f6a5429
Compare
|
Includes #730 since PPC crashes without it. |
f6a5429 to
d9168a0
Compare
CI in [1] seems to indicate that there are cases where the `f16` infinite recursion bug ([2], [3]) can make its way into what gets called during tests, even though this doesn't seem to be the usual case. In order to make sure that we avoid these completely, just unset `f16_enabled` on any platforms that have the recursion problem. This also refactors the `match` statement to be more in line with `library/std/build.rs`. [1]: rust-lang/compiler-builtins#729 [2]: llvm/llvm-project#97981 [3]: rust-lang/compiler-builtins#651
CI in [1] seems to indicate that there are cases where the `f16` infinite recursion bug ([2], [3]) can make its way into what gets called during tests, even though this doesn't seem to be the usual case. In order to make sure that we avoid these completely, just unset `f16_enabled` on any platforms that have the recursion problem. This also refactors the `match` statement to be more in line with `library/std/build.rs`. [1]: rust-lang/compiler-builtins#729 [2]: llvm/llvm-project#97981 [3]: rust-lang/compiler-builtins#651
CI in [1] seems to indicate that there are cases where the `f16` infinite recursion bug ([2], [3]) can make its way into what gets called during tests, even though this doesn't seem to be the usual case. In order to make sure that we avoid these completely, just unset `f16_enabled` on any platforms that have the recursion problem. This also refactors the `match` statement to be more in line with `library/std/build.rs`. [1]: #729 [2]: llvm/llvm-project#97981 [3]: #651
d95f341 to
9291a00
Compare
|
@quaternic would you mind double checking some of my logic here? With this current implementation, we are getting errors like the following: Which is coming from the bit of code here https://github.com/tgross35/compiler-builtins/blob/c462b7b5aa56a2ff3cdbfaf7c19143bbdee17b00/builtins-test/tests/conv.rs#L44-L79. I think the implementation is correct, especially considering the tests against apfloat seem okay. So I think this is an error in the validation algorithm here, which only shows up for f16 because As I'm typing it out that sounds pretty reasonable, just need to figure out how to patch this error algorithm. |
|
I think the validation logic is broken in that the apfloat-results that overflowed to infinity are converted back to an integer, specifically the maximum for the type, which should be irrelevant for the casting from integer to float. The overflow threshold is specifically when the exponent after rounding exceeds the maximum. But the rounding itself is done as if the exponent was unbounded. So for
|
|
Isn't that represented correctly? The apfloat bit at https://github.com/tgross35/compiler-builtins/blob/c462b7b5aa56a2ff3cdbfaf7c19143bbdee17b00/builtins-test/tests/conv.rs#L29-L37 should be the same as this: |
|
Lines 48-50 |
|
Ah, by
I thought you were referring to the test above that uses |
This comment has been minimized.
This comment has been minimized.
|
@quaternic forgot to follow up here, do you have an idea what would be better to write for the test assertion? |
|
@tgross35 — I've opened #1261, which builds on your implementation here to get integer-to- It's meant to supersede this PR, but I'm equally happy to fold the changes back into your branch instead if you'd rather keep it here — whichever you prefer. Thanks for the original work. |
| // The entire lower half of `i` will be truncated (masked portion), plus the | ||
| // next `EXP_BITS` bits. |
There was a problem hiding this comment.
Unless I'm missing something, I'm not sure the "(masked portion)" makes sense here, as nowhere is the lower half of i masked. The lower quarter of i_m is masked in the line below. (The code is correct as f16::EXP_BITS <= 8.)
| // next `EXP_BITS` bits. | ||
| let adj = (i_m >> f16::EXP_BITS | i_m & 0xFF) as u16; | ||
| let m = m_adj::<f16>(m_base, adj); | ||
| let e = if i == 0 { 0 } else { exp::<u32, f16>(n) - 1 }; |
There was a problem hiding this comment.
Not something that has to be changed in this PR, but is there any reason why some conversion do if i == 0 at the start of the function and some do it when calculating the exponent?
There was a problem hiding this comment.
I'm not sure, looks like that came with 7e5768b. Doing that here rather than the beginning makes it branchless, but I wonder if there's still an advantage to the early return? Would be interesting to benchmark.
There was a problem hiding this comment.
Found https://blog.m-ou.se/floats/#removing-the-last-branch which does specifically mention the branchless bit
|
Error: Failed to set assignee to
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
|
r? me |
These are not present in LLVM's `compiler-rt` but LLVM does emit them in some cases [1]. [1]: rust-lang/rust#132614 (comment)
c8b8949 to
75b0d62
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
These are not present in LLVM's
compiler-rtbut LLVM does emit them in some cases 1.