This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] SimplifyNodeWithTwoResults - ensure same legalization for LO/HI operands (PR21207)
ClosedPublic

Authored by RKSimon on Oct 21 2018, 5:35 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Oct 21 2018, 5:35 AM

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 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.

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)

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.

I don't think we have any other cases in DAGCombiner where we use !LegalOperations || TLI.isOperationLegalOrCustom

DAG combine hasn't always performed legalization on the fly after LegalizeDAG. So there used to only be one chance to legalize.

RKSimon updated this revision to Diff 174382.Nov 16 2018, 8:52 AM

Consistently use isOperationLegalOrCustom - I'll then close PR21207 as invalid now that we have legalization on the fly.

niravd accepted this revision.Nov 19 2018, 10:38 AM

LGTM.

This revision is now accepted and ready to land.Nov 19 2018, 10:38 AM
RKSimon edited the summary of this revision. (Show Details)Nov 19 2018, 11:26 AM
This revision was automatically updated to reflect the committed changes.