Oh yes, that's just LLVM's ConstantFoldCollatzConjecture pass, a basic optimization.
> That is, true for all value represent-able in usize.
A slight understatement!
But exactly the statement you need to fold it to a constant.
Sounds like it was working as intended, then! Doing a great job at it, too.
Sounds, rather, like it was doing the right thing in that case but for the wrong reasons!
But if we pass in an odd value that is more than half of the maximum value represented in a usize, we get an overflow and a panic when we make a recursive call with n * 3 + 1, right? We shouldn't be optimizing those away.
In the default release profile math wraps.
But does it converge using wrapping math for all usize values?
There might be a cycle in theory.
There can be a cycle but IIRC Rust inherits C/C++'s rule that infinite loops without side effects are undefined behaviour. So there are cycles (for example 0) but since there are no side effects and the only way to escape the loop is the `return true` the compiler only has to handle the `return true` path.
Oh sure that is fine, I just wonder if colatz is proven to converge for 32bit/64bit wrapping integer math.