4 comments

[ 3.3 ms ] story [ 21.5 ms ] thread
> surely the optimizer can reason that the float_abs operation produces a positive number!

how?

I don't understand why this article invents and explains a phony ranged-float fix when the real fix from the footnotes would have been just as simple to explain. The deception needlessly undermines the main point of the article, which I completely agree with.
Random note since Godbolt was mentioned: It's also fun to hop on play.rust-lang.org and see what different IRs look like via the "..." next to "RUN." Just look at how simple the HIR is pretty simple for "Hello world" - then check out the MIR ;)
I know about nothing about PyPy internals but

  case float_abs(_):
  -          return float
  +          return float.with_range(low=0, high=None)
to me, looks like a risky change. I would fear this could introduce a bug when computing

  isNaN(abs(NaN))
That should return true, but with that change, I fear it could return false because it informs the optimizer that abs never returns a NaN.