This is an archive of the discontinued LLVM Phabricator instance.

SelectionDAG switch lowering: Replace unreachable default with most popular case.
ClosedPublic

Authored by hans on Dec 3 2014, 11:22 AM.

Details

Summary

This can significantly reduce the size of the switch, allowing for more
efficient lowering.

SimplifyCFG currently does this transformation, but I'm working on
changing that to make it possible to exploit unreachable default cases.

I also worked with the idea of exploiting unreachable defaults by
omitting the range check for jump tables, but always ended up with a
non-neglible binary size increase. It might be worth looking into some more.

(This was broken out of http://reviews.llvm.org/D6471)

Diff Detail

Event Timeline

hans updated this revision to Diff 16875.Dec 3 2014, 11:22 AM
hans retitled this revision from to SelectionDAG switch lowering: Replace unreachable default with most popular case..
hans updated this object.
hans edited the test plan for this revision. (Show Details)
hans added a reviewer: majnemer.
hans added subscribers: Unknown Object (MLST), hansw.
majnemer added inline comments.Dec 5 2014, 4:33 PM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2714

DenseMap<const BasicBlock *, uint64_t>

2731–2738

How about remove_if(Cases.begin(), Cases.end(), ...

hans added inline comments.Dec 5 2014, 4:51 PM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2714

Done.

2731–2738

Nice :) Done.

hans updated this revision to Diff 17008.Dec 5 2014, 4:52 PM

Addressing David's comments.

majnemer added inline comments.Dec 5 2014, 4:55 PM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2732

const Case &C

majnemer accepted this revision.Dec 5 2014, 4:55 PM
majnemer edited edge metadata.

LGTM with tweaks.

This revision is now accepted and ready to land.Dec 5 2014, 4:55 PM
hans closed this revision.Dec 5 2014, 5:29 PM
hans updated this revision to Diff 17011.

Closed by commit rL223566 (authored by @hans).