Fix order change in comparisons when one side is not SEF.

The comment was wrong anyway. If one side changes x and the other side uses x, then order is still important, no matter whether one side is SEF.

But the reversal is safe when one side is a constant, so we still perform it, to enable optimization of some important cases.
This commit is contained in:
Sei Lisa 2017-10-27 11:03:35 +02:00
parent 106bb81543
commit c0176ad738

View file

@ -1158,10 +1158,11 @@ class foldconst(object):
self.FoldTree(parent, index)
return
if nt == '>':
if nt == '>' and ('SEF' in child[0] and 'SEF' in child[1]
or child[0]['nt'] == 'CONST' or child[1]['nt'] == 'CONST'
):
# Invert the inequalities to avoid doubling the cases to check.
# a>b -> b<a
# FIXME: This is only possible if at most one is non-SEF.
nt = node['nt'] = '<'
child[1], child[0] = child[0], child[1]
# fall through to check for '<'