4 ms·
It certainly does do this: https://rust.godbolt.org/z/ZaDAKa https://rust.godbolt.org/z/ZaDAKa Not just small constant powers either. I tried .powi(1000000) an
by raphlinus 7y ago
It certainly does do this: https://rust.godbolt.org/z/ZaDAKa https://rust.godbolt.org/z/ZaDAKa
Not just small constant powers either. I tried .powi(1000000) and it compiled into a sequence of 25 vmulss instructions.
- chias 7y agoInteresting, thank you! I suspect then that defining it at x*x is just just because it's easier to type than x.powi(2).