google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.58k stars 107 forks source link

Implement constant folding for casts to floating-point types. #1194

Closed axch closed 1 year ago

axch commented 1 year ago

Caveat: Did not check that they agree bit-for-bit with the runtime behavior, but any discrepancies should be small.

Benefit:

axch commented 1 year ago

Added some measure of consistency testing between run-time and compile-time casts. Unfortunately, it's hard to test many values, because compiling and running a million 1-instruction LLVM programs is much more expensive than executing a million LLVM instructions. That said, the tests did reveal two bugs (one already present and one introduced by me in the previous commit), which fixed.