From c0176ad738624ef20839fa56dde4a8cfa332bcb4 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 27 Oct 2017 11:03:35 +0200 Subject: [PATCH] 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. --- lslopt/lslfoldconst.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 05595e8..f742c1d 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -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