https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85758
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Alexander Monakov from comment #0) > However since m_3 is used, this is more costly. Shouldn't this folding check > for single use of the intermediate expr? From a quick look, this is probably > match.pd:/* Fold (X & Y) ^ Y and (X ^ Y) & Y as ~X & Y. */ Just as a note I'd consider ~X & Y cheaper canonicalization-wise because it has one unary and one binary op vs two binary ones. Yes, this is probably a candidate for :s With the current :s semantics :s should eventually be applied automagically by genmatch. Note that given match.pd patterns cannot rely on immediate uses being up-to-date all this is fragile heuristics anyways...