spcl / dace

DaCe - Data Centric Parallel Programming
http://dace.is/fast
BSD 3-Clause "New" or "Revised" License
499 stars 129 forks source link

Fix `pystr_to_symbolic` not correctly interpreting constants as boolean values in boolean comparisons #1756

Closed phschaad closed 1 week ago

phschaad commented 1 week ago

Strings like not ((N > 20) != 0) (== Not(Ne(Gt(N, 20), 0))) were incorrectly interpreted by sympy.sympify as constant "False". This is a limitation by sympy, which does not assume integer 0 to be a Falsy, and enforces exact equivalence (or difference) checks with Ne. To get around this limitation, the DaCe internal AST preprocessor now replaces constants with boolean values if they are arguments to Comparison operations, where the other operand is also a comparison operation, thus returning a boolean.

This fixes an issue with DeadStateElimination, closing issue #1129.