summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function.Anders Carlsson2011-03-211-15/+9
| | | | llvm-svn: 127997
* As suggested by Nick Lewycky, ignore debugging intrinsics when trying to ↵Anders Carlsson2011-03-211-0/+7
| | | | | | decide whether a destructor is empty or not. llvm-svn: 127985
* Fix commentsNick Lewycky2011-03-211-2/+2
| | | | llvm-svn: 127984
* Re-apply r127953 with fixes: eliminate empty return block if it has no ↵Evan Cheng2011-03-211-10/+122
| | | | | | predecessors; update dominator tree if cfg is modified. llvm-svn: 127981
* Don't try to eliminate invokes to __cxa_atexit.Anders Carlsson2011-03-201-0/+6
| | | | llvm-svn: 127976
* Don't segfault on mutual recursion, as pointed out by Frits.Anders Carlsson2011-03-201-4/+6
| | | | llvm-svn: 127975
* Address comments from Frits van Bommel.Anders Carlsson2011-03-201-7/+16
| | | | llvm-svn: 127974
* Add an optimization to GlobalOpt that eliminates calls to __cxa_atexit, if ↵Anders Carlsson2011-03-201-0/+101
| | | | | | the function passed is empty. llvm-svn: 127970
* Revert r127953, "SimplifyCFG has stopped duplicating returns into predecessorsDaniel Dunbar2011-03-191-99/+4
| | | | | | to canonicalize IR", it broke a lot of things. llvm-svn: 127954
* SimplifyCFG has stopped duplicating returns into predecessors to canonicalize IREvan Cheng2011-03-191-4/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to have single return block (at least getting there) for optimizations. This is general goodness but it would prevent some tailcall optimizations. One specific case is code like this: int f1(void); int f2(void); int f3(void); int f4(void); int f5(void); int f6(void); int foo(int x) { switch(x) { case 1: return f1(); case 2: return f2(); case 3: return f3(); case 4: return f4(); case 5: return f5(); case 6: return f6(); } } => LBB0_2: ## %sw.bb callq _f1 popq %rbp ret LBB0_3: ## %sw.bb1 callq _f2 popq %rbp ret LBB0_4: ## %sw.bb3 callq _f3 popq %rbp ret This patch teaches codegenprep to duplicate returns when the return value is a phi and where the phi operands are produced by tail calls followed by an unconditional branch: sw.bb7: ; preds = %entry %call8 = tail call i32 @f5() nounwind br label %return sw.bb9: ; preds = %entry %call10 = tail call i32 @f6() nounwind br label %return return: %retval.0 = phi i32 [ %call10, %sw.bb9 ], [ %call8, %sw.bb7 ], ... [ 0, %entry ] ret i32 %retval.0 This allows codegen to generate better code like this: LBB0_2: ## %sw.bb jmp _f1 ## TAILCALL LBB0_3: ## %sw.bb1 jmp _f2 ## TAILCALL LBB0_4: ## %sw.bb3 jmp _f3 ## TAILCALL rdar://9147433 llvm-svn: 127953
* If an AllocaInst referred by DbgDeclareInst is used by a LoadInst then the ↵Devang Patel2011-03-181-0/+24
| | | | | | LoadInst should also get a corresponding llvm.dbg.value intrinsic. llvm-svn: 127924
* Remove dead code.Devang Patel2011-03-181-2/+0
| | | | llvm-svn: 127923
* Consider debug info intrinsics pointing to null value as dead instructions.Devang Patel2011-03-181-1/+14
| | | | llvm-svn: 127922
* Remove TargetData and ValueTracking includes. I didn't mean for them to ↵Andrew Trick2011-03-181-4/+0
| | | | | | sneak in my last checkin. llvm-svn: 127842
* Added isValidRewrite() to check the result of ScalarEvolutionExpander.Andrew Trick2011-03-171-37/+82
| | | | | | | | | SCEV may generate expressions composed of multiple pointers, which can lead to invalid GEP expansion. Until we can teach SCEV to follow strict pointer rules, make sure no bad GEPs creep into IR. Fixes rdar://problem/9038671. llvm-svn: 127839
* whitespaceAndrew Trick2011-03-171-18/+18
| | | | llvm-svn: 127837
* Try to not lose variable's debug info during instcombine.Devang Patel2011-03-172-0/+30
| | | | | | | This is done by lowering dbg.declare intrinsic into dbg.value intrinsic. Radar 9143931. llvm-svn: 127834
* Refactor into a separate utility function.Devang Patel2011-03-172-29/+42
| | | | llvm-svn: 127832
* Fix a comment.Cameron Zwarich2011-03-161-3/+3
| | | | llvm-svn: 127728
* Only convert allocas to scalars if it is profitable. The profitability metric ICameron Zwarich2011-03-161-2/+16
| | | | | | | | | | | chose is having a non-memcpy/memset use and being larger than any native integer type. Originally I chose having an access of a size smaller than the total size of the alloca, but this caused some minor issues on the spirit benchmark where SRoA runs again after some inlining. This fixes <rdar://problem/8613163>. llvm-svn: 127718
* Better use initializer lists.Cameron Zwarich2011-03-161-5/+2
| | | | llvm-svn: 127716
* Add a clarifying comment.Cameron Zwarich2011-03-161-1/+1
| | | | llvm-svn: 127715
* Clean up something noticed by Fritz.Cameron Zwarich2011-03-151-1/+1
| | | | llvm-svn: 127684
* Do not add PHIs with no users when creating LCSSA form. Patch by Andrew Clinton.Cameron Zwarich2011-03-151-0/+10
| | | | llvm-svn: 127674
* PR9450: Make switch optimization in SimplifyCFG not dependent on the orderingEli Friedman2011-03-151-7/+18
| | | | | | of pointers in an std::map. llvm-svn: 127650
* If we don't know how long a string is we can't fold an _chk version to theEric Christopher2011-03-151-3/+7
| | | | | | | | normal version. Fixes rdar://9123638 llvm-svn: 127636
* Added SCEV::NoWrapFlags to manage unsigned, signed, and self wrapAndrew Trick2011-03-142-10/+20
| | | | | | | | | properties. Added the self-wrap flag for SCEV::AddRecExpr. A slew of temporary FIXMEs indicate the intention of the no-self-wrap flag without changing behavior in this revision. llvm-svn: 127590
* whitespaceAndrew Trick2011-03-141-66/+66
| | | | llvm-svn: 127589
* This case is solved by Scalar Replacement of Aggregates (DT) andJin-Gu Kang2011-03-141-25/+3
| | | | | | Early CSE pass so this patch reverts it to original source code. llvm-svn: 127574
* Add comment as following:Jin-Gu Kang2011-03-131-0/+12
| | | | | | | | | | | | | | | | | load and store reference same memory location, the memory location is represented by getelementptr with two uses (load and store) and the getelementptr's base is alloca with single use. At this point, instructions from alloca to store can be removed. (this pattern is generated when bitfield is accessed.) For example, %u = alloca %struct.test, align 4 ; [#uses=1] %0 = getelementptr inbounds %struct.test* %u, i32 0, i32 0;[#uses=2] %1 = load i8* %0, align 4 ; [#uses=1] %2 = and i8 %1, -16 ; [#uses=1] %3 = or i8 %2, 5 ; [#uses=1] store i8 %3, i8* %0, align 4 llvm-svn: 127565
* This patch removes some of useless instructions generated by bitfield access.Jin-Gu Kang2011-03-121-3/+13
| | | | llvm-svn: 127539
* Roll r127459 back in:Cameron Zwarich2011-03-111-0/+14
| | | | | | | | | | | Optimize trivial branches in CodeGenPrepare, which often get created from the lowering of objectsize intrinsics. Unfortunately, a number of tests were relying on llc not optimizing trivial branches, so I had to add an option to allow them to continue to test what they originally tested. This fixes <rdar://problem/8785296> and <rdar://problem/9112893>. llvm-svn: 127498
* Revert r127459, "Optimize trivial branches in CodeGenPrepare, which often getDaniel Dunbar2011-03-111-14/+0
| | | | | | created from the", it broke some GCC test suite tests. llvm-svn: 127477
* InstCombine: Fix a thinko where transform an icmp under the assumption that ↵Benjamin Kramer2011-03-111-3/+2
| | | | | | | | it's a zero comparison when it's not. Fixes PR9454. llvm-svn: 127464
* Optimize trivial branches in CodeGenPrepare, which often get created from theCameron Zwarich2011-03-111-0/+14
| | | | | | | | | | lowering of objectsize intrinsics. Unfortunately, a number of tests were relying on llc not optimizing trivial branches, so I had to add an option to allow them to continue to test what they originally tested. This fixes <rdar://problem/8785296> and <rdar://problem/9112893>. llvm-svn: 127459
* RecursivelyDeleteTriviallyDeadInstructions only needs aDan Gohman2011-03-101-3/+2
| | | | | | | | Value, not an Instruction, so casting is not necessary. Also, it's theoretically possible that the Value is not an Instruction, since WeakVH follows RAUWs. llvm-svn: 127427
* Fix reassociate to postpone certain instruction deletions untilDan Gohman2011-03-101-3/+11
| | | | | | | | | | after it has finished all of its reassociations, because its habit of unlinking operands and holding them in a datastructure while working means that it's not easy to determine when an instruction is really dead until after all its regular work is done. rdar://9096268. llvm-svn: 127424
* InstCombine: Turn umul_with_overflow into mul nuw if we can prove that it ↵Benjamin Kramer2011-03-101-1/+29
| | | | | | | | | | cannot overflow. This happens a lot in clang-compiled C++ code because it adds overflow checks to operator new[]: unsigned *foo(unsigned n) { return new unsigned[n]; } We can optimize away the overflow check on 64 bit targets because (uint64_t)n*4 cannot overflow. llvm-svn: 127418
* Preserve line number information while simplifying libcalls.Devang Patel2011-03-091-0/+3
| | | | llvm-svn: 127362
* These llvm.dbg.* constants are not used anymore.Devang Patel2011-03-091-3/+0
| | | | llvm-svn: 127352
* Fix a crasher introduced by r127317 that is seen on the bots when using anCameron Zwarich2011-03-091-18/+21
| | | | | | | alloca as both integer and floating-point vectors of the same size. Bugpoint is not cooperating with me, but I'll try to find a manual testcase tomorrow. llvm-svn: 127320
* Add support to scalar replacement for partial vector accesses of an alloca, e.g.Cameron Zwarich2011-03-091-12/+127
| | | | | | | | | | | | | | | | | a union of a float, <2 x float>, and <4 x float>. This mostly comes up with the use of vector intrinsics, especially in NEON when programmers know the layout of the register file. This enables codegen to eliminate a lot of the subregister traffic it would otherwise generate. This commit only enables this for a small number of floating-point cases, but a lot more integer cases. I assume this is okay for all ports, but I did not do extensive testing of the quality of code involving i512 vectors and the like. If there is a use case where this generates worse code than before, let me know and we can scale it back. This fixes <rdar://problem/9036264>. llvm-svn: 127317
* Move vector type merging to a separate function in preparation for it gettingCameron Zwarich2011-03-091-12/+23
| | | | | | more complicated. llvm-svn: 127316
* PR9346: Prevent SimplifyDemandedBits from incorrectly introducingEli Friedman2011-03-091-0/+4
| | | | | | INT_MIN % -1. llvm-svn: 127306
* PR9420; an instruction before an unreachable is guaranteed not to have anyEli Friedman2011-03-091-1/+3
| | | | | | | | reachable uses, but there still might be uses in dead blocks. Use the standard solution of replacing all the uses with undef. This is a rare case because it's very sensitive to phase ordering in SimplifyCFG. llvm-svn: 127299
* llvm.dbg.declare intrinsic does not use any llvm::Values. It's magic!Devang Patel2011-03-083-41/+3
| | | | llvm-svn: 127282
* Reorder comments to put them the right way around.Nick Lewycky2011-03-081-2/+2
| | | | llvm-svn: 127220
* While sinking an instruction, do not lose llvm.dbg.value intrinsic.Devang Patel2011-03-081-1/+2
| | | | llvm-svn: 127214
* Preserve line no. info.Devang Patel2011-03-071-2/+2
| | | | | | Radar 9097659 llvm-svn: 127182
* Add more analysis of the sign bit of an srem instruction. If the LHS is negativeNick Lewycky2011-03-071-0/+12
| | | | | | | then the result could go either way. If it's provably positive then so is the srem. Fixes PR9343 #7! llvm-svn: 127146
OpenPOWER on IntegriCloud