pydata/numexpr

Repeated constants are assigned same register but are still counted

Kirill888 opened this issue · 0 comments

Minimal reproducer:

from numexpr import NumExpr
print(NumExpr("(a + 1) * (a - 1)", [('a', float)]).constants)
######prints##########
(1.0, 1.0)

Looking at disassembly shows that the same register c3 is used for the constant, but it starts from 3, there is unused c2 that is allocated and populated but not accessed during evaluation.

[(b'add_fff', b'r0', b'r1[a]', b'c3[1.0]'),
 (b'sub_fff', b't4', b'r1[a]', b'c3[1.0]'),
 (b'mul_fff', b'r0', b'r0', b't4')]