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:
@@ -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 '<'
|
||||
|
||||
Reference in New Issue
Block a user