Take: ``` int f(int a, int c) { int b = a & c; return (a == 0) & b; } ``` This should be optimized to 0 but currently does not. There is a match pattern (via PR 111431) which is able to handle `a & (a == 0)` into `0`. reassociation knows how to handle `a & a` but it seems like if while doing reassociation, we should be to try to use match-and-simplify to simplify the f here.
b_5 = a_3(D) & c_4(D); _1 = a_3(D) == 0; _2 = (int) _1; _6 = b_5 & _2; return _6; I believe reassoc doesn't see that a and (int)(a == 0) are "related" when ranking ops of the AND, so it fails to appropriately order them and thus trigger the simplification. We definitely want to avoid doing n^2 matching combos of all AND operands. So confirmed, but not necessarily confirming the proposed solution.