A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
Result::unwrapunchecked writes to state but also assumes it is always an Ok value. The optimizer fails to remove branches that construct the Result currently, but succeeds if we tell it that the state_ is an Ok value before clobbering it.
Repeat the same thing in Result::unwrap_err_unchecked and in Option::unwrap_unchecked for good measure.
Result::unwrapunchecked writes to state but also assumes it is always an Ok value. The optimizer fails to remove branches that construct the Result currently, but succeeds if we tell it that the state_ is an Ok value before clobbering it.
Repeat the same thing in Result::unwrap_err_unchecked and in Option::unwrap_unchecked for good measure.
The difference can be seen in here: https://godbolt.org/z/Gax47shsb
Without it, the signed code generation is terrible. But with the optimizer hint, it's as good as working with ints directly.