This came about while I was investigating the lost bit extractions on D125836 - it didn't help but is a more general implementation than just matching AND masks.
With a bit more work I'm wondering how many of the 'isBitfieldExtractOp' patterns could actually be performed with just value tracking and SimplifyMultipleUseDemandedBits.
The pattern we're looking for is SRL+AND. The modified version of the function doesn't explicitly check for the "AND" operation at all. I guess you can describe "AND" as "an operation with known zero bits in the result, and can be eliminated by SimplifyMultipleUseDemandedBits", but that seems like an awfully confusing description.
How does this change actually generalize the matching in practice? Are we just looking for different AND masks, or can we actually match operations which aren't AND?
Maybe it would make the result easier to read if we extract the code that checks for the masking operation into a separate "MatchMaskOperation" function?