Consistently use (!LegalOperations || isOperationLegalOrCustom) for all node pairs.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I don't think that need to avoid custom operations post-legalization. The documentation doesn't seem to address this, but as I understand it, Custom is Legal but with non-standard lowering and we just happen to lower custom node in legalize as an easy way to sure we've legalized the DAG.
Can we solve the inconsistency the other way and allow custom in the other cases (L3568, L3584, L3594)?
I don't think we have any other cases in DAGCombiner where we use !LegalOperations || TLI.isOperationLegalOrCustom
which supports my supposition, but "hasOperation" seems to match your interpretation (maybe that's the right check here).
The initial PR21207 seems to only discuss reverting this particular case and states there are other cases in DAGCombiner (and I confirmed there are a few scattered about) .
If we return a custom node post-legalization it should be legalized into a non-custom node, so modulo causing an infinite chain of DAG changes (which we don't have any formal means of preventing anyways) shouldn't returning custom generally be okay? Do you have access to the OOT backend that's triggered PR21207?
(Side note: The 3rd and 4th optimization cases in this function looks redundant with the first two)
DAG combine hasn't always performed legalization on the fly after LegalizeDAG. So there used to only be one chance to legalize.
Consistently use isOperationLegalOrCustom - I'll then close PR21207 as invalid now that we have legalization on the fly.