Save a comparison (fixes a FIXME)

This commit is contained in:
Sei Lisa 2018-06-08 00:07:36 +02:00
parent 0808938894
commit e88e39127b

View file

@ -1347,8 +1347,6 @@ class foldconst(object):
node.ch = [child[a]]
return
#FIXME: Could remove one comparison
if nt == '&&' or nt == '||':
if nt == '||':
# Expand to its equivalent a || b -> !!(a | b)
node = nr(nt='|', t='integer', ch=[child[0], child[1]],
@ -1356,10 +1354,13 @@ class foldconst(object):
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
parent[index] = node
else:
# Make another pass with the substitution
self.FoldTree(parent, index)
elif nt == '&&':
# Expand to its equivalent a && b -> !(!a | !b)
orchildren = [
nr(nt='!',t='integer',ch=[child[0]],SEF=child[0].SEF),
nr(nt='!',t='integer',ch=[child[1]],SEF=child[1].SEF)
nr(nt='!', t='integer', ch=[child[0]], SEF=child[0].SEF),
nr(nt='!', t='integer', ch=[child[1]], SEF=child[1].SEF)
]
node = nr(nt='|', t='integer', ch=orchildren,
SEF=child[0].SEF and child[1].SEF)
@ -1367,7 +1368,6 @@ class foldconst(object):
parent[index] = node
# Make another pass with the substitution
self.FoldTree(parent, index)
return
return