Remove duplicate check for '|'

Removed the 'if' and applied an indentation change; no further changes are done.
This commit is contained in:
Sei Lisa 2017-10-17 23:59:41 +02:00
parent be767f24f0
commit 2bee2db148

View file

@ -348,48 +348,47 @@ class foldconst(object):
del val1, val2 del val1, val2
del a, b, c, d, and1, and2 del a, b, c, d, and1, and2
if nt == '|': # Absorb further flags, to allow chaining of &&
# Absorb further flags, to allow chaining of && # If ~r and s are constants, and s is a power of two:
# If ~r and s are constants, and s is a power of two: # (!~(x|~r) && x&s) -> !~(x|(~r&~s))
# (!~(x|~r) && x&s) -> !~(x|(~r&~s)) # This is implemented as:
# This is implemented as: # ~(x|~r) | !(x&s) -> ~(x|~(r|s))
# ~(x|~r) | !(x&s) -> ~(x|~(r|s)) # because that's the intermediate result after conversion of &&.
# because that's the intermediate result after conversion of &&. # a and b are going to be the children of the main |
# a and b are going to be the children of the main | # a is going to be child that has the ~
# a is going to be child that has the ~ # b is the other child (with the !)
# b is the other child (with the !) # c is the child of ~ which has x
# c is the child of ~ which has x # d is the child of ~ with the constant ~r
# d is the child of ~ with the constant ~r # e is the child of ! which has x
# e is the child of ! which has x # f is the child of ! with the constant s
# f is the child of ! with the constant s a, b = 0, 1
a, b = 0, 1 if child[a]['nt'] != '~':
if child[a]['nt'] != '~': a, b = b, a
a, b = b, a c, d = 0, 1
c, d = 0, 1 if child[a]['nt'] == '~' and child[a]['ch'][0]['nt'] == '|':
if child[a]['nt'] == '~' and child[a]['ch'][0]['nt'] == '|': if child[a]['ch'][0]['ch'][d]['nt'] != 'CONST':
if child[a]['ch'][0]['ch'][d]['nt'] != 'CONST': c, d = d, c
c, d = d, c e, f = 0, 1
e, f = 0, 1 if child[b]['nt'] == '!' and child[b]['ch'][0]['nt'] == '&':
if child[b]['nt'] == '!' and child[b]['ch'][0]['nt'] == '&': if child[b]['ch'][0]['ch'][f]['nt'] != 'CONST':
if child[b]['ch'][0]['ch'][f]['nt'] != 'CONST': e, f = f, e
e, f = f, e # All pointers are ready to check applicability.
# All pointers are ready to check applicability. if (child[a]['nt'] == '~' and child[a]['ch'][0]['nt'] == '|'
if (child[a]['nt'] == '~' and child[a]['ch'][0]['nt'] == '|' and child[b]['nt'] == '!' and child[b]['ch'][0]['nt'] == '&'
and child[b]['nt'] == '!' and child[b]['ch'][0]['nt'] == '&' ):
ch1 = child[a]['ch'][0]['ch']
ch2 = child[b]['ch'][0]['ch']
if (ch1[d]['nt'] == 'CONST' and ch2[f]['nt'] == 'CONST'
and (ch2[f]['value'] & (ch2[f]['value'] - 1)) == 0
): ):
ch1 = child[a]['ch'][0]['ch'] if self.CompareTrees(ch1[c], ch2[e]):
ch2 = child[b]['ch'][0]['ch'] # We're in that case. Apply optimization.
if (ch1[d]['nt'] == 'CONST' and ch2[f]['nt'] == 'CONST' parent[index] = child[a]
and (ch2[f]['value'] & (ch2[f]['value'] - 1)) == 0 ch1[d]['value'] &= ~ch2[f]['value']
): return
if self.CompareTrees(ch1[c], ch2[e]): del ch1, ch2
# We're in that case. Apply optimization.
parent[index] = child[a]
ch1[d]['value'] &= ~ch2[f]['value']
return
del ch1, ch2
del a, b, c, d, e, f del a, b, c, d, e, f
# Check if the operands are a negation ('!') or can be inverted # Check if the operands are a negation ('!') or can be inverted