This is an archive of the discontinued LLVM Phabricator instance.

Prevent binary-tree deterioration in sparse trees.
ClosedPublic

Authored by djasper on Jan 20 2015, 10:22 AM.

Details

Reviewers
hans
chandlerc
Summary

This address part of llvm.org/PR22262. Specifically, it prevents counting a single element as having a density of 1 and thereby outweighing all other split points.

This is not a complete solution but works around the most pressing issue.

Diff Detail

Event Timeline

djasper updated this revision to Diff 18443.Jan 20 2015, 10:22 AM
djasper retitled this revision from to Prevent binary-tree deterioration in sparse trees..
djasper updated this object.
djasper edited the test plan for this revision. (Show Details)
djasper added a reviewer: chandlerc.
djasper added a subscriber: Unknown Object (MLST).
chandlerc edited edge metadata.Jan 20 2015, 10:34 AM

If Hans is OK with this as an interim solution, I am too. I would still like to see us split off table regions.

hans accepted this revision.Jan 20 2015, 11:05 AM
hans added a reviewer: hans.
hans added a subscriber: hans.

I'm fine with this as an incremental improvement.

test/CodeGen/X86/switch-jump-table.ll
55 ↗(On Diff #18443)

I'm not sure this test is in the right file. Is there a file dealing with binary tree lowering issues? If not, maybe we should have one?

91 ↗(On Diff #18443)

Maybe this comment could be improved to reflect that 39 would be the ideal, but 29 is what it's currently doing. Otherwise, the diff between what the comment is saying and the test is testing could be confusing.

This revision is now accepted and ready to land.Jan 20 2015, 11:05 AM
djasper added inline comments.Jan 20 2015, 11:27 AM
test/CodeGen/X86/switch-jump-table.ll
55 ↗(On Diff #18443)

Moved to a different file.

91 ↗(On Diff #18443)

Done.

djasper updated this revision to Diff 18448.Jan 20 2015, 11:29 AM
djasper edited edge metadata.

Updated according to comments.
Also didn't just check for 1-element subsets, but for sets that are < TLI.getMinimumJumpTableEntries() as the density of those doesn't interest us.

hans added a comment.Jan 20 2015, 11:34 AM

Still lgtm.

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2434

Maybe add a comment about why we're doing this check?

djasper closed this revision.Jan 20 2015, 11:45 AM

Addressed comment and submitted as r226600.

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2434

Done.