This patch is meant to deal with an issue we encountered in an out of tree target. We have a lot of pre type legalization target specific combines in which we would like to take advantage of existing target independent combines.
For example we would like catch some patterns that include the abs node previously combined by the DAGCombiner.
Relying on the target independent abs combines, would save us copying the logic into the target itself.
The issue arises when we are dealing with illegal types in which case the target independent combines will not fire since they are guarded by TLI.isOperationLegalOrCustom which makes a check on the legality of the type.
We would like to allow the target to choose to combine even though the type is illegal.
This patch replaces the calls of isOperationLegalOrCustom just for the abs case to demonstrate but it may be relevant in other cases as well.
Details
Diff Detail
Event Timeline
Do you do custom type legalization for ABS in your target? There's no support for legalizing it in the target type independent legalizer.
ABS is only an example. We'd like to enable/disable the common transformation for other nodes as well.
Is it reasonable to add CombineLevel to the interface to make it more general?
We do. We rely on the DAGCombiner to combine abs for all types, and deal with type legalization in our target.
How do you get your target to be able to type legalize an abs of any type? The interface for enabling custom legalization requires calling setOperation with a specific type does it not?
What I meant was that we use the combined abs only in very specific scenarios and with specific types (some are illegal), and combine it to some other target specific node.
Actually, we don't use custom type legalization for the abs, so we will get an error if the abs has an illegal type.