aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* Use a heavy hammer to fix PR12573.Bill Wendling2012-04-181-0/+9
| | | | | | | | | | | | If the loop contains invoke instructions, whose unwind edge escapes the loop, then don't try to unswitch the loop. Doing so may cause the unwind edge to be split, which not only is non-trivial but doesn't preserve loop simplify information. Fixes PR12573 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154987 91177308-0d34-0410-b5e6-96231b3b80d8
* loop-reduce: Add an early bailout to catch extremely large loops.Andrew Trick2012-04-181-0/+17
| | | | | | | | | | | | | | This introduces a threshold of 200 IV Users, which is very conservative but should be sufficient to avoid serious compile time sink or stack overflow. The llvm test-suite with LTO never exceeds 190 users per loop. The bug doesn't relate to a specific type of loop. Checking in an arbitrary giant loop as a unit test would be silly. Fixes rdar://11262507. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154983 91177308-0d34-0410-b5e6-96231b3b80d8
* fix pr12559: mark unavailable win32 math libcallsJoe Groff2012-04-171-15/+10
| | | | | | also fix SimplifyLibCalls to use TLI rather than compile-time conditionals to enable optimizations on floor, ceil, round, rint, and nearbyint git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154960 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some comments, and fix a few places that missed setting Changed.Dan Gohman2012-04-131-2/+24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154687 91177308-0d34-0410-b5e6-96231b3b80d8
* Consider ObjC runtime calls objc_storeWeak and others which make a copy ofDan Gohman2012-04-131-14/+29
| | | | | | | | their argument as "escape" points for objc_retainBlock optimization. This fixes rdar://11229925. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154682 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new Use-aware dominates method to apply the objc runtimeDan Gohman2012-04-131-8/+5
| | | | | | | | library return value optimization for phi uses. Even when the phi itself is not dominated, the specific use may be dominated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154647 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't move objc_autorelease calls past autorelease pool boundaries whenDan Gohman2012-04-131-3/+43
| | | | | | | | optimizing autorelease calls on phi nodes with null operands. This fixes rdar://11207070. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154642 91177308-0d34-0410-b5e6-96231b3b80d8
* Typo.Chad Rosier2012-04-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154522 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix 12513: Loop unrolling breaks with indirect branches.Andrew Trick2012-04-101-29/+12
| | | | | | | | Take this opportunity to generalize the indirectbr bailout logic for loop transformations. CFG transformations will never get indirectbr right, and there's no point trying. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154386 91177308-0d34-0410-b5e6-96231b3b80d8
* whitespaceAndrew Trick2012-04-101-140/+140
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154385 91177308-0d34-0410-b5e6-96231b3b80d8
* Make GVN's propagateEquality non-recursive. No intended functionality change.Duncan Sands2012-04-061-98/+105
| | | | | | | The modifications are a lot more trivial than they appear to be in the diff! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154174 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix accidentally inverted logic from r152803, and make theDan Gohman2012-04-051-1/+1
| | | | | | | testcase slightly less trivial. This fixes rdar://11171718. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154118 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass the right sign to TLI->isLegalICmpImmediate.Jakob Stoklund Olesen2012-04-051-2/+11
| | | | | | | | | | | | | | | | | | LSR can fold three addressing modes into its ICmpZero node: ICmpZero BaseReg + Offset => ICmp BaseReg, -Offset ICmpZero -1*ScaleReg + Offset => ICmp ScaleReg, Offset ICmpZero BaseReg + -1*ScaleReg => ICmp BaseReg, ScaleReg The first two cases are only used if TLI->isLegalICmpImmediate() likes the offset. Make sure the right Offset sign is passed to this method in the second case. The ARM version is not symmetric. <rdar://problem/11184260> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154079 91177308-0d34-0410-b5e6-96231b3b80d8
* LoopUnrollPass: Use variable "Threshold" instead of "CurrentThreshold" whenHongbin Zheng2012-04-041-2/+2
| | | | | | | reducing unroll count, otherwise the reduced unroll count is not taking the "OptimizeForSize" attribute into account. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154007 91177308-0d34-0410-b5e6-96231b3b80d8
* Fast fix for PR12343:Stepan Dyatkovskiy2012-04-021-4/+29
| | | | | | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=12343 We have not trivial way for splitting edges that are goes from indirect branch. We can do it with some tricks, but it should be additionally discussed. And it is still dangerous due to difficulty of indirect branches controlling. Fix forbids this case for unswitching. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153879 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't PRE compares.Jakob Stoklund Olesen2012-03-291-1/+8
| | | | | | | | | | | | CodeGenPrepare sinks compare instructions down to their uses to prevent live flags and predicate registers across basic blocks. PRE of a compare instruction prevents that, forcing the i1 compare result into a general purpose register. That is usually more expensive than the redundant compare PRE was trying to eliminate in the first place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153657 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix 80-column violation.Chad Rosier2012-03-281-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153556 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR ivchain bug fix: corner case with ConstantExpr.Andrew Trick2012-03-261-2/+3
| | | | | | Fixes PR11950. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153463 91177308-0d34-0410-b5e6-96231b3b80d8
* comment typoAndrew Trick2012-03-261-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153462 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR cleanup: potential bug caught by PVS-Studio.Andrew Trick2012-03-261-2/+3
| | | | | | Thanks Andrey. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153451 91177308-0d34-0410-b5e6-96231b3b80d8
* Prune some includes and forward declarations.Craig Topper2012-03-261-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153429 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor the interface to recursively simplifying instructions to be tadChandler Carruth2012-03-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | bit simpler by handling a common case explicitly. Also, refactor the implementation to use a worklist based walk of the recursive users, rather than trying to use value handles to detect and recover from RAUWs during the recursive descent. This fixes a very subtle bug in the previous implementation where degenerate control flow structures could cause mutually recursive instructions (PHI nodes) to collapse in just such a way that From became equal to To after some amount of recursion. At that point, we hit the inf-loop that the assert at the top attempted to guard against. This problem is defined away when not using value handles in this manner. There are lots of comments claiming that the WeakVH will protect against just this sort of error, but they're not accurate about the actual implementation of WeakVHs, which do still track RAUWs. I don't have any test case for the bug this fixes because it requires running the recursive simplification on unreachable phi nodes. I've no way to either run this or easily write an input that triggers it. It was found when using instruction simplification inside the inliner when running over the nightly test-suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153393 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the MSVC build.Francois Pichet2012-03-241-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153366 91177308-0d34-0410-b5e6-96231b3b80d8
* More IndVarSimplify cleanup.Andrew Trick2012-03-241-25/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153362 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't convert objc_retainAutoreleasedReturnValue to objc_retain if itDan Gohman2012-03-231-2/+11
| | | | | | | is retaining the return value of an invoke that it immediately follows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153344 91177308-0d34-0410-b5e6-96231b3b80d8
* It's not possible to insert code immediately after an invoke in theDan Gohman2012-03-231-32/+42
| | | | | | | | | | | | | same basic block, and it's not safe to insert code in the successor blocks if the edges are critical edges. Splitting those edges is possible, but undesirable, especially on the unwind side. Instead, make the bottom-up code motion to consider invokes to be part of their successor blocks, rather than part of their parent blocks, so that it doesn't push code past them and onto the edges. This fixes PR12307. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153343 91177308-0d34-0410-b5e6-96231b3b80d8
* When propagating equalities, eg replacing A with B in every basic blockDuncan Sands2012-03-231-0/+3
| | | | | | | | | dominated by Root, check that B is available throughout the scope. This is obviously true (famous last words?) given the current logic, but the check may be helpful if more complicated reasoning is added one day. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153323 91177308-0d34-0410-b5e6-96231b3b80d8
* Indentation.Duncan Sands2012-03-231-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153322 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove -enable-lsr-retry in time for 3.1.Andrew Trick2012-03-221-20/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153287 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove -enable-lsr-nested in time for 3.1.Andrew Trick2012-03-221-29/+10
| | | | | | Tests cases have been removed but attached to open PR12330. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153286 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor the code for visiting instructions out into helper functions.Dan Gohman2012-03-221-245/+271
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153267 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove -enable-iv-rewrite, which has been unsupported since 3.0.Andrew Trick2012-03-221-265/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153260 91177308-0d34-0410-b5e6-96231b3b80d8
* don't use "signed", just something I noticed in patches flying by.Chris Lattner2012-03-221-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153237 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR fix: Add isSimplifiedLoopNest to IVUsers analysis.Andrew Trick2012-03-162-10/+18
| | | | | | | | | | | | | | Only record IVUsers that are dominated by simplified loop headers. Otherwise SCEVExpander will crash while looking for a preheader. I previously tried to work around this in LSR itself, but that was insufficient. This way, LSR can continue to run if some uses are not in simple loops, as long as we don't attempt to analyze those users. Fixes <rdar://problem/11049788> Segmentation fault: 11 in LoopStrengthReduce git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152892 91177308-0d34-0410-b5e6-96231b3b80d8
* Short term fix for pr12270 before we change dominates to handle unreachableRafael Espindola2012-03-151-29/+33
| | | | | | | code. While here, reduce indentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152803 91177308-0d34-0410-b5e6-96231b3b80d8
* This pass didn't want the inline cost per-se, it just wants generic codeChandler Carruth2012-03-151-1/+1
| | | | | | metrics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152760 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed a transform crash when setting a negative size value for memset. ↵Aaron Ballman2012-03-151-2/+6
| | | | | | Fixes PR12202. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152756 91177308-0d34-0410-b5e6-96231b3b80d8
* When an invoke is marked with metadata indicating its unwind edgeDan Gohman2012-03-141-1/+2
| | | | | | | | should be ignored by ARC optimization, don't insert new ARC runtime calls in the unwind destination. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152748 91177308-0d34-0410-b5e6-96231b3b80d8
* Target override to allow CodeGenPrepare to sink address operands to ↵Pete Cooper2012-03-131-0/+9
| | | | | | intrinsics in the same way it current does for loads and stores git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152666 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance jump threading to preserve TBAA information when PRE'ing loads,Chris Lattner2012-03-131-1/+12
| | | | | | | | fixing rdar://11039258, an issue that came up when inspecting clang's bootstrapped codegen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152635 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm::SwitchInstStepan Dyatkovskiy2012-03-114-8/+8
| | | | | | | | | Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default. Added some notes relative to case iterators. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152532 91177308-0d34-0410-b5e6-96231b3b80d8
* Add statistics on removed switch cases, and fix the phi statisticDuncan Sands2012-03-091-1/+5
| | | | | | | to count the number of phis changed, not the number visited. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152425 91177308-0d34-0410-b5e6-96231b3b80d8
* When identifying exit nodes for the reverse-CFG reverse-post-orderDan Gohman2012-03-091-2/+8
| | | | | | | | | | traversal, consider nodes for which the only successors are backedges which the traversal is ignoring to be exit nodes. This fixes a problem where the bottom-up traversal was failing to visit split blocks along split loop backedges. This fixes rdar://10989035. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152421 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate switch cases that can never match, for example removes allDuncan Sands2012-03-091-0/+86
| | | | | | | | negative switch cases if the branch condition is known to be positive. Inspired by a recent improvement to GCC's VRP. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152405 91177308-0d34-0410-b5e6-96231b3b80d8
* Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:Stepan Dyatkovskiy2012-03-084-26/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*". ConstCaseIt is just a read-only iterator. CaseIt is read-write iterator; it allows to change case successor and case value. Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters. Main way of iterator usage looks like this: SwitchInst *SI = ... // intialize it somehow for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) { BasicBlock *BB = i.getCaseSuccessor(); ConstantInt *V = i.getCaseValue(); // Do something. } If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method. If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method. There are also related changes in llvm-clients: klee and clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152297 91177308-0d34-0410-b5e6-96231b3b80d8
* This is not a common case, in fact it never happens!Duncan Sands2012-03-051-4/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152027 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace the ad-hoc hashing in GVN with the new hashing infrastructure.Chandler Carruth2012-03-051-10/+13
| | | | | | | | | | | | | | | | | This implicitly fixes a nasty bug in the GVN hashing (that thankfully could only manifest as a performance bug): actually include the opcode in the hash. The old code started the hash off with the opcode, but then overwrote it with the type pointer. Since this is likely to be pretty hot (GVN being already pretty expensive) I've included a micro-optimization to just not bother with the varargs hashing if they aren't present. I can't measure any change in GVN performance due to this, even with a big test case like Duncan's sqlite one. Everything I see is in the noise floor. That said, this closes a loop hole for a potential scaling problem due to collisions if the opcode were the differentiating aspect of the expression. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152025 91177308-0d34-0410-b5e6-96231b3b80d8
* Nick pointed out on IRC that GVN's propagateEquality wasn't propagatingDuncan Sands2012-03-041-1/+11
| | | | | | | | | | | equalities into phi node operands for which the equality is known to hold in the incoming basic block. That's because replaceAllDominatedUsesWith wasn't handling phi nodes correctly in general (that this didn't give wrong results was just luck: the specific way GVN uses replaceAllDominatedUsesWith precluded wrong changes to phi nodes). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152006 91177308-0d34-0410-b5e6-96231b3b80d8
* Do trivial CSE of dead BBs during codegen preparation.Bill Wendling2012-03-041-1/+20
| | | | | | | | | Some BBs can become dead after codegen preparation. If we delete them here, it could help enable tail-call optimizations later on. <rdar://problem/10256573> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152002 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an iterator invalidation problem. operator[] on a DenseMapDan Gohman2012-03-021-8/+28
| | | | | | | | can insert a new element, invalidating iterators. Use find instead, and handle the case where the key is not found explicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151871 91177308-0d34-0410-b5e6-96231b3b80d8