[HN Gopher] A DSL for peephole transformation rules of integer o...
___________________________________________________________________
A DSL for peephole transformation rules of integer operations in
the PyPy JIT
Author : todsacerdoti
Score : 66 points
Date : 2024-10-23 16:31 UTC (6 hours ago)
(HTM) web link (pypy.org)
(TXT) w3m dump (pypy.org)
| fweimer wrote:
| GCC does this match.pd. Here's the add_zero example, I think:
| /* Simplifications of operations with one constant operand and
| simplifications to constants or single values. */
| (for op (plus pointer_plus minus bit_ior bit_xor)
| (simplify (op @0 integer_zerop)
| (non_lvalue @0)))
|
| https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/match.pd
|
| The floating point case can be more complicated because of signed
| zeros and signaling NaNs, see fold_real_zero_addition_p.
| westurner wrote:
| math.fma fused multiply add is in Python 3.13. Are there already
| rules to transform expressions to math.fma?
|
| And does Z3 verification indicate differences in output due to
| minimizing float-rounding error?
|
| https://docs.python.org/3/library/math.html#math.fma :
|
| > _math.fma(x, y, z)_
|
| > _Fused multiply-add operation. Return (x * y) + z, computed as
| though with infinite precision and range followed by a single
| round to the float format. This operation often provides better
| accuracy than the direct expression (x * y) + z._
|
| > _This function follows the specification of the
| fusedMultiplyAdd operation described in the IEEE 754 standard._
| cfbolztereick wrote:
| I only support integer operations in the DSL so far.
|
| (but yes, turning the python expression x*y+z into an fma call
| would not be a legal optimization for the jit anyway. And Z3
| would rightfully complain. The results must be bitwise
| identical before and after optimization)
| mjcohen wrote:
| Interesting to see which optimizations are never used.
| hoten wrote:
| The before/after delta is very satisfying and clearly easier to
| work with. Very nice.
|
| How does the DSL handle side effects? I'm assuming any term here
| could be a compound expression, so what part of the system
| prevents "0*callfn()" from reducing to "0"?
___________________________________________________________________
(page generated 2024-10-23 23:00 UTC)