This is a revamp of what started as a target specific patch. Basically xalan (corrected, I originally thought it was perlbench) has a bitset implementation with a bit of an oddity. Specifically setBit will clear the bit before it is set: > if (bitToSet < 32) > { > fBits1 &= ~mask; > fBits1 |= mask; > } > else > { > fBits2 &= ~mask; > fBits2 |= mask; > } We can clean this up pretty easily in RTL with a small bit of code in simplify-rtx. While xalan doesn't have other cases, we can synthesize tests pretty easily and handle them as well. It turns out we don't actually have to recognize this stuff at the bit level, just standard logical identities are sufficient. For example (X | Y) & ~Y -> X & ~Y Andrew P. might poke at this at the gimple level. The type changes kindof get in the way in gimple but he's much better at match.pd than I am, so if he wants to chase it from the gimple side, I'll fully support that. Bootstrapped and regression tested on x86. Also run through my tester on its embedded targets. Pushing to the trunk. jeff