This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Move AND nodes to multiple load leaves
ClosedPublic

Authored by samparker on Dec 13 2017, 5:24 AM.

Details

Summary

rL319773 was reverted due to a recursive issue causing timeouts. This happened because I failed to check whether the discovered loads could be narrowed further. In the cases of narrow loads that could not be further narrowed, an AND was being introduced and not combined away - only to be combined into another AND and so on... forever.

Diff Detail

Repository
rL LLVM

Event Timeline

samparker created this revision.Dec 13 2017, 5:24 AM

So if the Load is the same size as the mask, we used insert an AND but we don't end up eliding it? That seems like a fence post error elsewhere and it may be worth checking that out.

In any case, this change looks good. LGTM. Next time reopen the old revision, and update it. That way we can see the diffs directly on phabricator.

niravd accepted this revision.Dec 13 2017, 6:26 AM
This revision is now accepted and ready to land.Dec 13 2017, 6:26 AM

Ok, thanks. In this case the AND does get combined with the load, but a node also needs to be fixed up and so introduces another masking AND. This AND is then later combined with another node, in the process I assume added to the worklist, and then later hits visitAND. visitAND tries to combine with a load, which it does, but it also performs the fix up again, beginning the process again. I'm going to add another test case to satisfy myself that this works.

This revision was automatically updated to reflect the committed changes.
samparker reopened this revision.Dec 15 2017, 8:11 AM
This revision is now accepted and ready to land.Dec 15 2017, 8:11 AM
samparker updated this revision to Diff 127137.Dec 15 2017, 8:15 AM

rL320679 was reverted due to a miscompilation. I had made the false assumption that constant operands would have been narrowed. So now any OR and XOR nodes which use constant operands, which are wider than the mask, have their operand narrowed at the end of the process.

I'm unsure how I've managed to accept the revision...

The previous acceptance still applies. You can explicitly request a review

I'm unsure how I've managed to accept the revision...

niravd accepted this revision.Dec 15 2017, 9:22 AM

Do you have a reasonable test case of the failing case you can add?

LGTM otherwise.

samparker added a comment.EditedDec 18 2017, 12:37 AM

Yes, the newly added 'test9' function was taken from the reproducer. I've also added 'test10'.

This revision was automatically updated to reflect the committed changes.