aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* Revert this in an attempt to bring the builders back.Eric Christopher2011-02-101-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125257 91177308-0d34-0410-b5e6-96231b3b80d8
* Turn this pass ordering:Cameron Zwarich2011-02-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Natural Loop Information Loop Pass Manager Canonicalize natural loops Scalar Evolution Analysis Loop Pass Manager Induction Variable Users Canonicalize natural loops Induction Variable Users Loop Strength Reduction into this: Scalar Evolution Analysis Loop Pass Manager Canonicalize natural loops Induction Variable Users Loop Strength Reduction This fixes <rdar://problem/8869639>. I also filed PR9184 on doing this sort of thing automatically, but it seems easier to just change the ordering of the passes if this is the only case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125254 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't split any loop backedges, including backedges of loops other thanDan Gohman2011-02-081-15/+17
| | | | | | | | | the active loop. This is generally desirable, and it avoids trouble in situations such as the testcase in PR9123, though the failure mode depends on use-list order, so it is infeasible to test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125065 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix reassociate to clear optional flags, such as nsw.Dan Gohman2011-02-021-0/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124712 91177308-0d34-0410-b5e6-96231b3b80d8
* Unbreak the MSVC build.Francois Pichet2011-01-291-0/+1
| | | | | | The DEBUG() call at line 606 demands to see raw_ostream's definition. I have no idea why this seems to only break MSVC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124545 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a test for TCE return duplication.Evan Cheng2011-01-291-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124527 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-apply r124518 with fix. Watch out for invalidated iterator.Evan Cheng2011-01-291-19/+108
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124526 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r124518. It broke Linux self-host.Evan Cheng2011-01-291-105/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124522 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-commit r124462 with fixes. Tail recursion elim will now dup ret into ↵Evan Cheng2011-01-291-19/+105
| | | | | | unconditional predecessor to enable TCE on demand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124518 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR9039, a use-after-free in reassociate. The issue was that theDuncan Sands2011-01-261-4/+11
| | | | | | | | | operand being factorized (and erased) could occur several times in Ops, resulting in freed memory being used when the next occurrence in Ops was analyzed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124287 91177308-0d34-0410-b5e6-96231b3b80d8
* Give GetUnderlyingObject a TargetData, to keep it in syncDan Gohman2011-01-243-5/+6
| | | | | | | | | | | | with BasicAA's DecomposeGEPExpression, which recently began using a TargetData. This fixes PR8968, though the testcase is awkward to reduce. Also, update several off GetUnderlyingObject's users which happen to have a TargetData handy to pass it in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124134 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance SRoA to promote allocas that are used by PHI nodes. This oftenChris Lattner2011-01-241-26/+157
| | | | | | | | | | | occurs because instcombine sinks loads and inserts phis. This kicks in on such apps as 175.vpr, eon, 403.gcc, xalancbmk and a bunch of times in spec2006 in some app that uses std::deque. This resolves the last of rdar://7339113. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124090 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance SRoA to promote allocas that are used by selects in someChris Lattner2011-01-231-1/+132
| | | | | | | | | | | | | | | | | | | | | | common cases. This triggers a surprising number of times in SPEC2K6 because min/max idioms end up doing this. For example, code from the STL ends up looking like this to SRoA: %202 = load i64* %__old_size, align 8, !tbaa !3 %203 = load i64* %__old_size, align 8, !tbaa !3 %204 = load i64* %__n, align 8, !tbaa !3 %205 = icmp ult i64 %203, %204 %storemerge.i = select i1 %205, i64* %__n, i64* %__old_size %206 = load i64* %storemerge.i, align 8, !tbaa !3 We can now promote both the __n and the __old_size allocas. This addresses another chunk of rdar://7339113, poor codegen on stringswitch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124088 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance SRoA to be more aggressive about scalarization of aggregate allocasChris Lattner2011-01-231-12/+114
| | | | | | | | | | | | | | that have PHI or select uses of their element pointers. This can often happen when instcombine sinks two loads into a successor, inserting a phi or select. With this patch, we can scalarize the alloca, but the pinned elements are not yet promoted. This is still a win for large aggregates where only one element is used. This fixes rdar://8904039 and part of rdar://7339113 (poor codegen on stringswitch). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124070 91177308-0d34-0410-b5e6-96231b3b80d8
* have AllocaInfo store the alloca being inspected, simplifying callers.Chris Lattner2011-01-231-22/+24
| | | | | | | No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124067 91177308-0d34-0410-b5e6-96231b3b80d8
* Rearrange some code a bit. Change MarkUnsafe to Chris Lattner2011-01-231-27/+29
| | | | | | | | | handle the "Transformation preventing inst" printing, so that -scalarrepl -debug will always print the rejected instruction. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124066 91177308-0d34-0410-b5e6-96231b3b80d8
* remove an old hack that avoided creating MMX datatypes. TheChris Lattner2011-01-231-22/+1
| | | | | | | X86 backend has been fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124064 91177308-0d34-0410-b5e6-96231b3b80d8
* Actually check memcpy lengths, instead of just commenting aboutDan Gohman2011-01-211-2/+4
| | | | | | | how they should be checked. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123999 91177308-0d34-0410-b5e6-96231b3b80d8
* SCCP doesn't actually preserve the CFG. It will delete and insert terminatorNick Lewycky2011-01-211-4/+0
| | | | | | | instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123973 91177308-0d34-0410-b5e6-96231b3b80d8
* fix rdar://8878965, a regression I introduced with the recentChris Lattner2011-01-181-1/+3
| | | | | | | llvm.objectsize changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123771 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove code for updating dominance frontiers and some outdated references toCameron Zwarich2011-01-183-9/+1
| | | | | | | dominance and post-dominance frontiers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123725 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove outdated references to dominance frontiers.Cameron Zwarich2011-01-182-19/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123724 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove dead code, that I apparently wrote a while back. We seem to be doing ↵Owen Anderson2011-01-171-15/+0
| | | | | | | | | | | well enough without whatever this was trying to do. When/if someone has the time to do some empirical evaluations, it might be worth it to figure out what this code was trying to do and see if it's worth resurrecting/fixing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123684 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll r123609 back in with two changes that fix test failures with expensiveCameron Zwarich2011-01-171-7/+2
| | | | | | | | | | | | | | | checks enabled: 1) Use '<' to compare integers in a comparison function rather than '<='. 2) Use the uniqued set DefBlocks rather than Info.DefiningBlocks to initialize the priority queue. The speedup of scalarrepl on test-suite + SPEC2000 + SPEC2006 is a bit less, at just under 16% rather than 17%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123662 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll out r123609 due to failures on the llvm-x86_64-linux-checks bot.Cameron Zwarich2011-01-171-2/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123618 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate the use of dominance frontiers in PromoteMemToReg. In addition toCameron Zwarich2011-01-171-7/+2
| | | | | | | | | | | | | | eliminating a potentially quadratic data structure, this also gives a 17% speedup when running -scalarrepl on test-suite + SPEC2000 + SPEC2006. My initial experiment gave a greater speedup around 25%, but I moved the dominator tree level computation from dominator tree construction to PromoteMemToReg. Since this approach to computing IDFs has a much lower overhead than the old code using precomputed DFs, it is worth looking at using this new code for the second scalarrepl pass as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123609 91177308-0d34-0410-b5e6-96231b3b80d8
* tidy up a comment, as suggested by duncanChris Lattner2011-01-161-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123590 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify a littleChris Lattner2011-01-161-7/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123573 91177308-0d34-0410-b5e6-96231b3b80d8
* if an alloca is only ever accessed as a unit, and is accessed with ↵Chris Lattner2011-01-161-3/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | load/store instructions, then don't try to decimate it into its individual pieces. This will just make a mess of the IR and is pointless if none of the elements are individually accessed. This was generating really terrible code for std::bitset (PR8980) because it happens to be lowered by clang as an {[8 x i8]} structure instead of {i64}. The testcase now is optimized to: define i64 @test2(i64 %X) { br label %L2 L2: ; preds = %0 ret i64 %X } before we generated: define i64 @test2(i64 %X) { %sroa.store.elt = lshr i64 %X, 56 %1 = trunc i64 %sroa.store.elt to i8 %sroa.store.elt8 = lshr i64 %X, 48 %2 = trunc i64 %sroa.store.elt8 to i8 %sroa.store.elt9 = lshr i64 %X, 40 %3 = trunc i64 %sroa.store.elt9 to i8 %sroa.store.elt10 = lshr i64 %X, 32 %4 = trunc i64 %sroa.store.elt10 to i8 %sroa.store.elt11 = lshr i64 %X, 24 %5 = trunc i64 %sroa.store.elt11 to i8 %sroa.store.elt12 = lshr i64 %X, 16 %6 = trunc i64 %sroa.store.elt12 to i8 %sroa.store.elt13 = lshr i64 %X, 8 %7 = trunc i64 %sroa.store.elt13 to i8 %8 = trunc i64 %X to i8 br label %L2 L2: ; preds = %0 %9 = zext i8 %1 to i64 %10 = shl i64 %9, 56 %11 = zext i8 %2 to i64 %12 = shl i64 %11, 48 %13 = or i64 %12, %10 %14 = zext i8 %3 to i64 %15 = shl i64 %14, 40 %16 = or i64 %15, %13 %17 = zext i8 %4 to i64 %18 = shl i64 %17, 32 %19 = or i64 %18, %16 %20 = zext i8 %5 to i64 %21 = shl i64 %20, 24 %22 = or i64 %21, %19 %23 = zext i8 %6 to i64 %24 = shl i64 %23, 16 %25 = or i64 %24, %22 %26 = zext i8 %7 to i64 %27 = shl i64 %26, 8 %28 = or i64 %27, %25 %29 = zext i8 %8 to i64 %30 = or i64 %29, %28 ret i64 %30 } In this case, instcombine was able to eliminate the nonsense, but in PR8980 enough PHIs are in play that instcombine backs off. It's better to not generate this stuff in the first place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123571 91177308-0d34-0410-b5e6-96231b3b80d8
* Use an irbuilder to get some trivial constant folding when doing a storeChris Lattner2011-01-161-21/+17
| | | | | | | of a constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123570 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance FoldOpIntoPhi in instcombine to try harder when a phi hasChris Lattner2011-01-161-0/+1
| | | | | | | | | multiple uses. In some cases, all the uses are the same operation, so instcombine can go ahead and promote the phi. In the testcase this pushes an add out of the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123568 91177308-0d34-0410-b5e6-96231b3b80d8
* temporarily revert r123526. While working on a follow-on patch IChris Lattner2011-01-151-3/+0
| | | | | | | realize that ConstantFoldTerminator doesn't preserve dominfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123527 91177308-0d34-0410-b5e6-96231b3b80d8
* fix rdar://8785296 - -fcatch-undefined-behavior generates inefficient codeChris Lattner2011-01-151-0/+3
| | | | | | | | | | The basic issue is that isel (very reasonably!) expects conditional branches to be folded, so CGP leaving around a bunch dead computation feeding conditional branches isn't such a good idea. Just fold branches on constants into unconditional branches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123526 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify code, no functionality change.Chris Lattner2011-01-151-30/+37
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123525 91177308-0d34-0410-b5e6-96231b3b80d8
* Now that instruction optzns can update the iterator as they go, we can Chris Lattner2011-01-151-10/+16
| | | | | | | | | | have objectsize folding recursively simplify away their result when it folds. It is important to catch this here, because otherwise we won't eliminate the cross-block values at isel and other times. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123524 91177308-0d34-0410-b5e6-96231b3b80d8
* make the current instruction iterator an ivar, allowing xforms thatChris Lattner2011-01-151-35/+38
| | | | | | | | potentially invalidate it (like inline asm lowering) to be sunk into their proper place, cleaning up a ton of code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123523 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize LoadAndStorePromoter a bit and switch LICMChris Lattner2011-01-152-174/+86
| | | | | | | to use it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123501 91177308-0d34-0410-b5e6-96231b3b80d8
* switch SRoA to use LoadAndStorePromoter instead of its own copy of the code.Chris Lattner2011-01-141-136/+26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123457 91177308-0d34-0410-b5e6-96231b3b80d8
* split SROA into two passes: one that uses DomFrontiers (-scalarrepl) Chris Lattner2011-01-142-27/+57
| | | | | | | and one that uses SSAUpdater (-scalarrepl-ssa) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123436 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement full support for promoting allocas to registers using SSAUpdaterChris Lattner2011-01-141-5/+162
| | | | | | | | | | | | instead of DomTree/DomFrontier. This may be interesting for reducing compile time. This is currently disabled, but seems to work just fine. When this is enabled, we eliminate two runs of dominator frontier, one in the "early per-function" optimizations and one in the "interlaced with inliner" function passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123434 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix whitespace.Bob Wilson2011-01-131-120/+120
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123396 91177308-0d34-0410-b5e6-96231b3b80d8
* Check for empty structs, and for consistency, zero-element arrays.Bob Wilson2011-01-131-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123383 91177308-0d34-0410-b5e6-96231b3b80d8
* Extend SROA to handle arrays accessed as homogeneous structs and vice versa.Bob Wilson2011-01-131-14/+57
| | | | | | | | | | | | | | | | | This is a minor extension of SROA to handle a special case that is important for some ARM NEON operations. Some of the NEON intrinsics return multiple values, which are handled as struct types containing multiple elements of the same vector type. The corresponding return types declared in the arm_neon.h header have equivalent arrays. We need SROA to recognize that it can split up those arrays and structs into separate vectors, even though they are not always accessed with the same type. SROA already handles loads and stores of an entire alloca by using insertvalue/extractvalue to access the individual pieces, and that code works the same regardless of whether the type is a struct or an array. So, all that needs to be done is to check for compatible arrays and homogeneous structs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123381 91177308-0d34-0410-b5e6-96231b3b80d8
* Make SROA more aggressive with allocas containing padding.Bob Wilson2011-01-131-34/+27
| | | | | | | SROA only split up structs and arrays one level at a time, so padding can only cause trouble if it is located in between the struct or array elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123380 91177308-0d34-0410-b5e6-96231b3b80d8
* Use SmallVector instead of SmallPtrSet and avoid non-deterministic behavior.Devang Patel2011-01-121-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123318 91177308-0d34-0410-b5e6-96231b3b80d8
* revert 123144, reenabling the rest of memset formation.Chris Lattner2011-01-121-3/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123302 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r123146 which disabled code that wasn't the root causeChris Lattner2011-01-121-2/+0
| | | | | | | of the bootstrap miscompare issue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123299 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r123149, reenabling an improvement to memcpyopt that wasn'tChris Lattner2011-01-121-4/+2
| | | | | | | the source of the bootstrap problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123298 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the PR8954 workaround.Jakob Stoklund Olesen2011-01-111-4/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123288 91177308-0d34-0410-b5e6-96231b3b80d8
* Dial back the speculative fix for PR8954 a bit, so that we only recompute ↵Cameron Zwarich2011-01-111-1/+3
| | | | | | | | | dominators once at the beginning of GVN instead of once per iteration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123278 91177308-0d34-0410-b5e6-96231b3b80d8