Switch-to-lookup tables: set threshold to 3 cases

Press ? to show keyboard shortcuts.
Committed
hansJan 14 2014, 9:00 PM
Parents
rL199293: Check the error code and save a call to sys::fs::exists.
Branches
Unknown
Tags
Unknown
Subscribers
None
Description

Switch-to-lookup tables: set threshold to 3 cases

There has been an old FIXME to find the right cut-off for when it's worth
analyzing and potentially transforming a switch to a lookup table.

The switches always have two or more cases. I could not measure any speed-up
by transforming a switch with two cases. A switch with three cases gets a nice
speed-up, and I couldn't measure any compile-time regression, so I think this
is the right threshold.

In a Clang self-host, this causes 480 new switches to be transformed,
and reduces the final binary size with 8 KB.

rL199294

llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Loading...

llvm/trunk/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll

Loading...

Add Comment