This patch is in 2 parts that can be committed separately if desired:
1 - replace combineBT's use of SimplifyDemandedBits (hasOneUse only) with SelectionDAG::GetDemandedBits to more aggressively determine the lower bits used by BT.
2 - update SelectionDAG::GetDemandedBits to support ANY_EXTEND - if the demanded bits are only in the non-extended portion, then peek through and demand from the source value and then ANY_EXTEND that if we found a match.
This doesn't seem right to me. Doesn't that get the upper SrcBitWidth bits of Mask? But the extended bits should be (BitWidth - SrcBitWidth) right?
But in any case can't this be 'if (Mask.getActiveBits() > SrcBitWidth)' which would avoid a temporary APInt.