summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG
Commit message (Collapse)AuthorAgeFilesLines
...
* Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ↵Dmitri Gribenko2012-12-302-2/+2
| | | | | | | | ModuleID This is done to avoid odd test failures, like the one fixed in r171243. llvm-svn: 171246
* Fix logic to determine whether to turn a switch into a lookup table. WhenEvan Cheng2012-11-301-0/+26
| | | | | | | | | the tables cannot fit in registers (i.e. bitmap), do not emit the table if it's using an illegal type. rdar://12779436 llvm-svn: 168970
* Only do switch-to-lookup table transformation when TargetTransformInfoHans Wennborg2012-11-073-4/+9
| | | | | | 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
* Use TargetTransformInfo to control switch-to-lookup table transformationHans Wennborg2012-10-302-0/+38
| | | | | | | | | | | | | | When the switch-to-lookup tables transform landed in SimplifyCFG, it was pointed out that this could be inappropriate for some targets. Since there was no way at the time for the pass to know anything about the target, an awkward reverse-transform was added in CodeGenPrepare that turned lookup tables back into switches for some targets. This patch uses the new TargetTransformInfo to determine if a switch should be transformed, and removes CodeGenPrepare::ConvertLoadToSwitch. llvm-svn: 167011
* 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: Enhance the "remove CFG edge that leads to null pointer ↵Benjamin Kramer2012-10-041-0/+28
| | | | | | | | | | dereference" optimization to also handle instructions with multiple uses. We conservatively only check the first use to avoid walking long use chains. This catches the common case of having both a load and a store to a pointer supplied by a PHI node. llvm-svn: 165232
* 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: sink common codes from IF, ELSE blocks down to END block.Manman Ren2012-09-201-0/+53
| | | | | | | | | | | | We already have HoistThenElseCodeToIf, this patch implements SinkThenElseCodeToEnd. When END block has only two predecessors and each predecessor terminates with unconditional branches, we compare instructions in IF and ELSE blocks backwards and check whether we can sink the common instructions down. rdar://12191395 llvm-svn: 164325
* 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
* PGO: preserve branch-weight metadata when simplifying Switch to a sub, an icmpManman Ren2012-09-181-1/+47
| | | | | | and a conditional branch; also when removing dead cases from a switch. llvm-svn: 164084
* PGO: preserve branch-weight metadata when simplifying SwitchManman Ren2012-09-171-1/+36
| | | | | | | Hanlde the case when we split the default edge if the default target has "icmp" and unconditinal branch. llvm-svn: 164076
* PGO: preserve branch-weight metadata when simplifying SwitchOnSelect.Manman Ren2012-09-171-1/+26
| | | | llvm-svn: 164068
* PGO: preserve branch-weight metadata when simplifying two branches with a commonManman Ren2012-09-171-1/+22
| | | | | | destination in SimplifyCondBranchToCondBranch. llvm-svn: 164054
* PGO: preserve branch-weight metadata when simplifying two branches with a commonManman Ren2012-09-151-1/+22
| | | | | | | | | | | | | | | | destination. Updated previous implementation to fix a case not covered: // PBI: br i1 %x, TrueDest, BB // BI: br i1 %y, TrueDest, FalseDest The other case was handled correctly. // PBI: br i1 %x, BB, FalseDest // BI: br i1 %y, TrueDest, FalseDest Also tried to use 64-bit arithmetic instead of APInt with scale to simplify the computation. Let me know if you have other opinions about this. llvm-svn: 163954
* PGO: preserve branch-weight metadata when simplifying a switch with a singleManman Ren2012-09-141-1/+49
| | | | | | case to a conditional branch and when removing dead cases. llvm-svn: 163942
* PGO: preserve branch-weight metadata when merging two switches whereManman Ren2012-09-141-0/+48
| | | | | | | the default target of the first switch is not the basic block the second switch is in (PredDefault != BB). llvm-svn: 163916
* PGO: preserve branch-weight metadata when removing a case which jumpsManman Ren2012-09-121-1/+33
| | | | | | to the default target. llvm-svn: 163724
* SimplifyCFG: preserve branch-weight metadata when creating a new switch fromManman Ren2012-09-111-0/+92
| | | | | | | | | | | | | a pair of switch/branch where both depend on the value of the same variable and the default case of the first switch/branch goes to the second switch/branch. Code clean up and fixed a few issues: 1> handling the case where some cases of the 2nd switch are invalidated 2> correctly calculate the weight for the 2nd switch when it is a conditional eq Testing case is modified from Alastair's original patch. llvm-svn: 163635
* Remove an incorrect assert during branch weight propagation.Andrew Trick2012-09-081-0/+37
| | | | | | Patch and test case by Alastair Murray! llvm-svn: 163437
* 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-062-2/+143
| | | | | | | | | | | | | | | | | | | | | | 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
* The normal edge of an invoke is not allowed to branch to a block with aEli Friedman2012-08-103-1151/+0
| | | | | | landingpad. Enforce it in the verifier, and fix the regression tests to match. llvm-svn: 161697
* fix PR13339 (remove the predecessor from the unwind BB when removing an invoke)Nuno Lopes2012-07-161-0/+22
| | | | llvm-svn: 160325
* Revert "IntRange:" as it appears to be breaking self hosting.Eric Christopher2012-07-021-1/+1
| | | | | | This reverts commit b2833d9dcba88c6f0520cad760619200adc0442c. llvm-svn: 159618
* Fix the remaining TCL-style quotes found in the testsuite. This isChandler Carruth2012-07-027-7/+7
| | | | | | | | | | | | | | | | | another mechanical change accomplished though the power of terrible Perl scripts. I have manually switched some "s to 's to make escaping simpler. While I started this to fix tests that aren't run in all configurations, the massive number of tests is due to a really frustrating fragility of our testing infrastructure: things like 'grep -v', 'not grep', and 'expected failures' can mask broken tests all too easily. Essentially, I'm deeply disturbed that I can change the testsuite so radically without causing any change in results for most platforms. =/ llvm-svn: 159547
* fix the regression I introduced in r159385 (it's necessary to update PHI ↵Nuno Lopes2012-07-021-0/+33
| | | | | | nodes in unwind BB llvm-svn: 159534
* IntRange:Stepan Dyatkovskiy2012-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | - Changed isSingleNumber method behaviour. Now this flag is calculated on demand. IntegersSubsetMapping - Optimized diff operation. - Replaced type of Items field from std::list with std::map. - Added new methods: bool isOverlapped(self &RHS) void add(self& RHS, SuccessorClass *S) void detachCase(self& NewMapping, SuccessorClass *Succ) void removeCase(SuccessorClass *Succ) SuccessorClass *findSuccessor(const IntTy& Val) const IntTy* getCaseSingleNumber(SuccessorClass *Succ) IntegersSubsetTest - DiffTest: Added checks for successors. SimplifyCFG Updated SwitchInst usage (now it is case-ragnes compatible) for - SimplifyEqualityComparisonWithOnlyPredecessor - FoldValueComparisonIntoPredecessors llvm-svn: 159527
* Convert all tests using TCL-style quoting to use shell-style quoting.Chandler Carruth2012-07-025-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | This was done through the aid of a terrible Perl creation. I will not paste any of the horrors here. Suffice to say, it require multiple staged rounds of replacements, state carried between, and a few nested-construct-parsing hacks that I'm not proud of. It happens, by luck, to be able to deal with all the TCL-quoting patterns in evidence in the LLVM test suite. If anyone is maintaining large out-of-tree test trees, feel free to poke me and I'll send you the steps I used to convert things, as well as answer any painful questions etc. IRC works best for this type of thing I find. Once converted, switch the LLVM lit config to use ShTests the same as Clang. In addition to being able to delete large amounts of Python code from 'lit', this will also simplify the entire test suite and some of lit's architecture. Finally, the test suite runs 33% faster on Linux now. ;] For my 16-hardware-thread (2x 4-core xeon e5520): 36s -> 24s llvm-svn: 159525
* make simplifyCFG erase invokes to readonly/readnone functionsNuno Lopes2012-06-281-1/+40
| | | | llvm-svn: 159385
* improve optimization of invoke instructions:Nuno Lopes2012-06-251-0/+45
| | | | | | | | - simplifycfg: invoke undef/null -> unreachable - instcombine: invoke new -> invoke expect(0, 0) (an arbitrary NOOP intrinsic; only done if the allocated memory is unused, of course) - verifier: allow invoke of intrinsics (to make the previous step work) llvm-svn: 159146
* Remove dyn_cast + dereference pattern by replacing it with a cast and changingNick Lewycky2012-06-241-0/+18
| | | | | | | the safety check to look for the same type we're going to actually cast to. Fixes PR13180! llvm-svn: 159110
* SimplifyCFG: fold unconditional branch to its predecessor if profitable.Manman Ren2012-06-131-0/+33
| | | | | | | | | | This patch extends FoldBranchToCommonDest to fold unconditional branches. For unconditional branches, we fold them if it is easy to update the phi nodes in the common successors. rdar://10554090 llvm-svn: 158392
* Replace all instances of dg.exp file with lit.local.cfg, since all tests are ↵Eli Bendersky2012-02-162-3/+1
| | | | | | | | run with LIT now and now Dejagnu. dg.exp is no longer needed. Patch reviewed by Daniel Dunbar. It will be followed by additional cleanup patches. llvm-svn: 150664
* The 'unwind' instruction is deprecated and will be removed, making this testBill Wendling2012-02-061-6/+0
| | | | | | obsolete. llvm-svn: 149880
* Make Value::isDereferenceablePointer() handle unreachable code blocks. (ThisNick Lewycky2012-01-231-0/+28
| | | | | | | | returns false in the event the computation feeding into the pointer is unreachable, which maybe ought to be true -- but this is at least consistent with undef->isDereferenceablePointer().) Fixes PR11825! llvm-svn: 148671
* Fix SpeculativelyExecuteBB to either speculate all or none of the phisDan Gohman2012-01-055-6/+55
| | | | | | | | | | | | present in the bottom of the CFG triangle, as the transformation isn't ever valuable if the branch can't be eliminated. Also, unify some heuristics between SimplifyCFG's multiple if-converters, for consistency. This fixes rdar://10627242. llvm-svn: 147630
* Revert r56315. When the instruction to speculate is a load, thisDan Gohman2012-01-051-1/+1
| | | | | | | | code can incorrectly move the load across a store. This never happens in practice today, but only because the current heuristics accidentally preclude it. llvm-svn: 147623
* FileCheck hygiene.Benjamin Kramer2012-01-051-1/+1
| | | | llvm-svn: 147580
* Teach simplifycfg to recompute branch weights when merging some branches, andNick Lewycky2011-12-271-2/+64
| | | | | | | to discard weights when appropriate. Still more to do (and a new TODO), but it's a start! llvm-svn: 147286
* Update the branch weight metadata when reversing the order of a branch.Nick Lewycky2011-12-261-0/+26
| | | | llvm-svn: 147280
* Make some intrinsics safe to speculatively execute.Nick Lewycky2011-12-211-3/+28
| | | | llvm-svn: 147036
* Revert r146822 at Pete Cooper's request as it broke clang self hosting.Kevin Enderby2011-12-171-152/+0
| | | | | | Hope I did this correctly :) llvm-svn: 146834
* SimplifyCFG now predicts some conditional branches to true or false ↵Pete Cooper2011-12-171-0/+152
| | | | | | | | | | | | | depending on previous branch on same comparison operands. For example, if (a == b) { if (a > b) // this is false Fixes some of the issues on <rdar://problem/10554090> llvm-svn: 146822
OpenPOWER on IntegriCloud