Simplify operands of bitwise OR expressions as booleans. Deals with a TODO in a more general way.

This commit is contained in:
Sei Lisa 2015-03-28 20:16:06 +01:00
parent 6813bb0458
commit de33c2df01

View file

@ -128,7 +128,10 @@ class foldconst(object):
self.FoldTree(parent, index)
if nt == '|':
#TODO: simplify !!a|b or a|!!b -> a|b
# In a boolean context, the operands count as booleans.
self.FoldCond(child, 0)
self.FoldCond(child, 1)
a, b = 0, 1
if child[a]['nt'] == 'CONST':
a, b = 1, 0