From c9f73bd4295c8add86fc3d3e149572ec3261c479 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 24 Dec 2018 17:04:30 +0100 Subject: [PATCH] Extend an optimization to cover some (admittedly rare) cases. The value of bool|const is const when bit 0 of const is 1. This is a generalization of the case bool|1 = 1. --- lslopt/lslfoldconst.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 2cb4f4e..0bbe4b5 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -1363,11 +1363,11 @@ class foldconst(object): return if (nt == '|' and (val == -1 - or val == 1 and self.IsBool(child[a])) + or (val & 1) == 1 and self.IsBool(child[a])) or nt == '&' and val == 0 ): # a|-1 -> -1 if a is SEF - # a|1 -> 1 if a is bool and SEF + # a|C -> C if bit 0 of C is 1 and a is bool and SEF # a&0 -> 0 if a is SEF if child[a].SEF: parent[index] = child[b]