The AMDGPU target has a 24-bit multiply instruction. In SimplifyDemandedBits I’d like to be able to turn a generic i32 ISD::MUL into AMDGPUISD::MUL_I24 if only the low order 24 bits are demanded. Currently it seems like there’s no way to do that, because the target hook SimplifyDemandedBitsForTargetNode is only called for target-specific nodes, not for generic nodes like MUL.
Would it be acceptable to call the target hook for generic nodes as well? Here’s a patch to show the general idea: https://reviews.llvm.org/D89964
(It probably needs a bit of polish, e.g. the name “SimplifyDemandedBitsForTargetNode” is misleading now.)
In the future perhaps “demanded bits” could become a cached analysis that could be queried from anywhere. Then I could write a target-specific DAG combine for MUL that would query the demanded bits for the node to do this transformation.