Hi, On Tue, 2 Aug 2011, Kai Tietz wrote:
> this patch improves the ability of reassociation pass to simplifiy > more complex bitwise-binary > operations with comparisons. We break-up for this patch statements > like (X | Y) != 0 to X != 0 | Y != 0, > and (X | Y) == 0 to expanded X == 0 & Y == 0. > Additionally we expand logical-not expressions like ~(A & B) -> ~A | > ~B, ~(A & B) -> ~A | ~B, and > ~(A ^ B) -> A ^ ~B. These expansion are just temporary for this pass > and getting later by fold > reversed again back to their original form. Implement all of this in the normal reassoc machinery that already exists. Don't implement your own walker (which btw is superlinear because you recurse into both operands). If no simplifications were possible you have to fold back the NOTs into the shorter sequences again, which conveniently reassoc already can do for negates and PLUS/MINUS chains. Hence extend the existing support for arithmetic operations to logical operations. Ciao, Michael.