Page MenuHomePhabricator

[DAGCombiner] Allow target to control combine with illegal types.
Needs ReviewPublic

Authored by alonkom on Jan 3 2019, 7:28 AM.

Details

Summary

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.

Diff Detail

Event Timeline

alonkom created this revision.Jan 3 2019, 7:28 AM
RKSimon added a subscriber: llvm-commits.

Do you do custom type legalization for ABS in your target? There's no support for legalizing it in the target type independent legalizer.

There is this patch that was trying to make ABS more available D50239

D49837 is a generic patch to handle SPF_ABS/SPF_NABS in SelectionDAGBuilder::visitSelect - @ikulagin are you still looking at this?

D49837 is a generic patch to handle SPF_ABS/SPF_NABS in SelectionDAGBuilder::visitSelect - @ikulagin are you still looking at this?

I am waiting for feedback and I want to coordinate the activity.

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?

Do you do custom type legalization for ABS in your target? There's no support for legalizing it in the target type independent legalizer.

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?

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.