opteryx
opteryx copied to clipboard
✨ [OPTIMIZER] Further Logical Rewrites
Idempotent Operations
Operations with the same operand on each side can be simplified.
A and A => A
A or A => A
Absorption and Reduction
A or (A and B) => A
A and (A or B) => A
Null elimination
Because nothing equals Null, Null checks can be eliminated in some cases, e.g.
A is not NULL and A = B => A = B
Tautologies and Contradictions
A or FALSE => A
A or TRUE => TRUE
A and FALSE => FALSE
A and TRUE => A
Distributive Laws
A and (B or C) => (A and B) or (A and C)
which may be more useful in reverse to extract A for pushing
(A and B) or (A and C) => A and (B or C)
Commutativity and Associativity
(A and B) and C => A and (B and C) => A and B and C
XOR rules
not(A xor B) => A = B
A xor A => FALSE
A xor TRUE => not A
A xor FALSE => A
A xor A xor B => B
(A and not B) or (not A and B) => A xor B
(A or B) and not (A and B) => A xor B