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.
This commit is contained in:
Sei Lisa 2018-12-24 17:04:30 +01:00
parent 141301d7ff
commit c9f73bd429

View file

@ -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]