summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll
Commit message (Collapse)AuthorAgeFilesLines
* Only do switch-to-lookup table transformation when TargetTransformInfoHans Wennborg2012-11-071-779/+0
| | | | | | is available. llvm-svn: 167552
* Fix bad test IR in switch_to_lookup_table.llHans Wennborg2012-11-071-1/+1
| | | | llvm-svn: 167543
* Remove fixme about unreachable cases from SwitchToLookupTableHans Wennborg2012-10-311-0/+32
| | | | | | SimplifyCFG will have removed those cases for us. llvm-svn: 167132
* Do simple constant propagation in lookup table formation for switchesHans Wennborg2012-10-311-0/+41
| | | | | | | | | | | | | | | | | | | By propagating the value for the switch condition, LLVM can now build lookup tables for code such as: switch (x) { case 1: return 5; case 2: return 42; case 3: case 4: case 5: return x - 123; default: return 123; } Given that x is known for each case, "x - 123" becomes a constant for cases 3, 4, and 5. llvm-svn: 167115
* switch_to_lookup_table.ll: Remove some unnecessary lines, comments,Hans Wennborg2012-10-301-625/+214
| | | | | | function attributes, etc. llvm-svn: 167016
* Also optimize large switch statements.Jakob Stoklund Olesen2012-10-251-0/+822
| | | | | | | | | | The isValueEqualityComparison() guard at the top of SimplifySwitch() only applies to some of the possible transformations. The newer transformations work just fine on large switches, and the check on predecessor count is nonsensical. llvm-svn: 166710
* SimplifyCFG: Don't crash when forming a switch bitmap with an undef default ↵Benjamin Kramer2012-10-011-0/+24
| | | | | | | | value. Fixes PR13985. llvm-svn: 164934
* Fix a integer overflow in SimplifyCFG's look up table formation logic.Benjamin Kramer2012-09-271-0/+38
| | | | | | | | If the width is very large it gets truncated from uint64_t to uint32_t when passed to TD->fitsInLegalInteger. The truncated value can fit in a register. This manifested in massive memory usage or crashes (PR13946). llvm-svn: 164784
* Address Duncan's comments on r164684:Hans Wennborg2012-09-261-2/+2
| | | | | | | | - Put statistics in alphabetical order - Don't use getZextValue when building TableInt, just use APInts - Introduce Create{Z,S}ExtOrTrunc in IRBuilder. llvm-svn: 164696
* SimplifyCFG: Make the switch-to-lookup table transformation store theHans Wennborg2012-09-261-14/+73
| | | | | | | | | | | | | | | | tables in bitmaps when they fit in a target-legal register. This saves some space, and it also allows for building tables that would otherwise be deemed too sparse. One interesting case that this hits is example 7 from http://blog.regehr.org/archives/320. We currently generate good code for this when lowering the switch to the selection DAG: we build a bitmask to decide whether to jump to one block or the other. My patch will result in the same bitmask, but it removes the need for the jump, as the return value can just be retrieved from the mask. llvm-svn: 164684
* SimplifyCFG: Don't generate invalid code for switch used to initializeHans Wennborg2012-09-191-0/+34
| | | | | | | | | | | | | two variables where the first variable is returned and the second ignored. I don't think this occurs in practice (other passes should have cleaned up the unused phi node), but it should still be handled correctly. Also make the logic for determining if we should return early less sketchy. llvm-svn: 164225
* Fix switch_to_lookup_table.ll test from r163302.Hans Wennborg2012-09-061-6/+6
| | | | | | | | The lookup tables did not get built in a deterministic order. This makes them get built in the order that the corresponding phi nodes were found. llvm-svn: 163305
* Build lookup tables for switches (PR884)Hans Wennborg2012-09-061-0/+140
This adds a transformation to SimplifyCFG that attemps to turn switch instructions into loads from lookup tables. It works on switches that are only used to initialize one or more phi nodes in a common successor basic block, for example: int f(int x) { switch (x) { case 0: return 5; case 1: return 4; case 2: return -2; case 5: return 7; case 6: return 9; default: return 42; } This speeds up the code by removing the hard-to-predict jump, and reduces code size by removing the code for the jump targets. llvm-svn: 163302
OpenPOWER on IntegriCloud