summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* rewrite operand loops to use iteratorsGabor Greif2008-05-301-24/+26
| | | | llvm-svn: 51789
* Since LCSSA switched over to DenseMap, we have to be more careful to avoid ↵Owen Anderson2008-05-301-4/+5
| | | | | | iterator invalidation. Fixes PR2385. llvm-svn: 51777
* Use eraseFromParent() instead of doing that manually in two places.Matthijs Kooijman2008-05-301-2/+2
| | | | llvm-svn: 51770
* const-ify getOpcode.Dan Gohman2008-05-291-3/+3
| | | | llvm-svn: 51698
* Add a newline at the end of this file.Duncan Sands2008-05-291-1/+1
| | | | llvm-svn: 51680
* Replace the old ADCE implementation with a new one that more simply solvesOwen Anderson2008-05-291-457/+62
| | | | | | | | | the one case that ADCE catches that normal DCE doesn't: non-induction variable loop computations. This implementation handles this problem without using postdominators. llvm-svn: 51668
* Remove debugging code.Owen Anderson2008-05-291-5/+1
| | | | llvm-svn: 51666
* convert more operand loops to iterator formulationGabor Greif2008-05-292-23/+29
| | | | llvm-svn: 51663
* Implement PR2370: memmove(x,x,size) -> noop.Chris Lattner2008-05-281-0/+4
| | | | llvm-svn: 51636
* Fix some constructs that gcc-4.4 warns about.Duncan Sands2008-05-272-3/+4
| | | | llvm-svn: 51591
* InequalityGraph::node() can create new nodes, invalidating iterators acrossNick Lewycky2008-05-271-0/+1
| | | | | | | the set of nodes. Fix makeEqual to handle this by creating the new node first then iterating across them second. llvm-svn: 51573
* Grammaro.Nick Lewycky2008-05-261-1/+1
| | | | llvm-svn: 51572
* Factor code to copy global value attributes likeDuncan Sands2008-05-266-27/+11
| | | | | | | | | | | | | | | the section or the visibility from one global value to another: copyAttributesFrom. This is particularly useful for duplicating functions: previously this was done by explicitly copying each attribute in turn at each place where a new function was created out of an old one, with the result that obscure attributes were regularly forgotten (like the collector or the section). Hopefully now everything is uniform and nothing is forgotten. llvm-svn: 51567
* Use a DenseMap instead of an std::map, speeding up the testcase in PR2368 by ↵Owen Anderson2008-05-261-3/+3
| | | | | | about a third. llvm-svn: 51565
* "ret (constexpr)" can't be folded into a Constant. Add a method toNick Lewycky2008-05-251-0/+10
| | | | | | | | | | Analysis/ConstantFolding to fold ConstantExpr's, then make instcombine use it to try to use targetdata to fold constant expressions on void instructions. Also extend the icmp(inttoptr, inttoptr) folding to handle the case where int size != ptr size. llvm-svn: 51559
* Fix a serious brain-o. Obviously no-one reviewed my patch :(Chris Lattner2008-05-241-2/+4
| | | | | | This fixes PR2359 llvm-svn: 51536
* Fix PR2358 by resolving calls with undef arguments to overdefined.Chris Lattner2008-05-241-0/+6
| | | | llvm-svn: 51535
* Remove x86.sse2.loadh.pd and x86.sse2.loadl.pd. These will be lowered into ↵Evan Cheng2008-05-241-5/+0
| | | | | | load and shuffle instructions. llvm-svn: 51521
* Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places toDan Gohman2008-05-2314-52/+26
| | | | | | use it instead of duplicating its functionality. llvm-svn: 51499
* Replace some weird usage of UserOp1 introduced in r49492 by a plain if.Matthijs Kooijman2008-05-231-1/+3
| | | | llvm-svn: 51482
* Restucture a part of the SimplifyCFG pass and include a testcase.Matthijs Kooijman2008-05-231-65/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The SimplifyCFG pass looks at basic blocks that contain only phi nodes, followed by an unconditional branch. In a lot of cases, such a block (BB) can be merged into their successor (Succ). This merging is performed by TryToSimplifyUncondBranchFromEmptyBlock. It does this by taking all phi nodes in the succesor block Succ and expanding them to include the predecessors of BB. Furthermore, any phi nodes in BB are moved to Succ and expanded to include the predecessors of Succ as well. Before attempting this merge, CanPropagatePredecessorsForPHIs checks to see if all phi nodes can be properly merged. All functional changes are made to this function, only comments were updated in TryToSimplifyUncondBranchFromEmptyBlock. In the original code, CanPropagatePredecessorsForPHIs looks quite convoluted and more like stack of checks added to handle different kinds of situations than a comprehensive check. In particular the first check in the function did some value checking for the case that BB and Succ have a common predecessor, while the last check in the function simply rejected all cases where BB and Succ have a common predecessor. The first check was still useful in the case that BB did not contain any phi nodes at all, though, so it was not completely useless. Now, CanPropagatePredecessorsForPHIs is restructured to to look a lot more similar to the code that actually performs the merge. Both functions now look at the same phi nodes in about the same order. Any conflicts (phi nodes with different values for the same source) that could arise from merging or moving phi nodes are detected. If no conflicts are found, the merge can happen. Apart from only restructuring the checks, two main changes in functionality happened. Firstly, the old code rejected blocks with common predecessors in most cases. The new code performs some extra checks so common predecessors can be handled in a lot of cases. Wherever common predecessors still pose problems, the blocks are left untouched. Secondly, the old code rejected the merge when values (phi nodes) from BB were used in any other place than Succ. However, it does not seem that there is any situation that would require this check. Even more, this can be proven. Consider that BB is a block containing of a single phi node "%a" and a branch to Succ. Now, since the definition of %a will dominate all of its uses, BB will dominate all blocks that use %a. Furthermore, since the branch from BB to Succ is unconditional, Succ will also dominate all uses of %a. Now, assume that one predecessor of Succ is not dominated by BB (and thus not dominated by Succ). Since at least one use of %a (but in reality all of them) is reachable from Succ, you could end up at a use of %a without passing through it's definition in BB (by coming from X through Succ). This is a contradiction, meaning that our original assumption is wrong. Thus, all predecessors of Succ must also be dominated by BB (and thus also by Succ). This means that moving the phi node %a from BB to Succ does not pose any problems when the two blocks are merged, and any use checks are not needed. llvm-svn: 51478
* Indent fix.Matthijs Kooijman2008-05-231-2/+2
| | | | llvm-svn: 51477
* Constant integer vectors may also be negated.Nick Lewycky2008-05-231-0/+5
| | | | llvm-svn: 51476
* Typo.Nick Lewycky2008-05-231-1/+1
| | | | llvm-svn: 51475
* Revert X + X --> X * 2 optz'n which pessimizes heavily on x86.Nick Lewycky2008-05-231-13/+5
| | | | llvm-svn: 51474
* Implement X + X for vectors.Nick Lewycky2008-05-231-5/+13
| | | | llvm-svn: 51472
* Fix a recently added optimization to not crash on vectors.Nick Lewycky2008-05-231-2/+10
| | | | llvm-svn: 51471
* Generalize the new code in instcombine's ComputeNumSignBits for handlingDan Gohman2008-05-231-44/+9
| | | | | | | and/or to handle more cases (such as this add-sitofp.ll testcase), and port it to selectiondag's ComputeNumSignBits. llvm-svn: 51469
* Use isSingleValueType instead of isFirstClassType toDan Gohman2008-05-231-2/+2
| | | | | | exclude struct and array types. llvm-svn: 51467
* Allow for switch with no cases. Was causing faultDale Johannesen2008-05-231-0/+2
| | | | | | in gcc.dg/pr27531-1.c. llvm-svn: 51464
* Use isSingleValueType instead of isFirstClassType toDan Gohman2008-05-232-5/+5
| | | | | | exclude struct and array types. llvm-svn: 51459
* Use isSingleValueType instead of isFirstClassType toDan Gohman2008-05-232-2/+2
| | | | | | exclude struct and array types. llvm-svn: 51456
* rewrite the validity checking for memory promotion to be simpler,Chris Lattner2008-05-221-49/+52
| | | | | | | more aggressive, and more correct. Verify that we only attempt to promote loads and stores. llvm-svn: 51406
* Use 'continue' to reduce nesting in this loop. No functionality change.Chris Lattner2008-05-221-54/+51
| | | | llvm-svn: 51399
* When LSR is replacing an instruction, callDan Gohman2008-05-211-7/+10
| | | | | | | | | | | | | | | | | | | | ScalarEvolution::deleteValueFromRecords on it before doing the replaceAllUsesWith, because ScalarEvolution looks at the instruction's users to find SCEV references to the instruction's SCEV object in its internal maps. Move all of LSR's loop-related state clearing after processing the loop and before cleaning up dead PHI nodes. This eliminates all of LSR's SCEV references just before the calls to ScalarEvolution::deleteValueFromRecords so that when ScalarEvolution drops its own SCEV references, the reference counts will reach zero and the SCEVs will be deleted immediately. These changes fix some compiler aborts involving ScalarEvolution holding onto and reusing SCEV objects for instructions that have been deleted. No regression test unfortunately; because the symptoms were due to dangling pointers, reduced testcases ended up being fairly arbitrary. llvm-svn: 51359
* Port SelectionDAG's ComputeNumSignBits-using code to instcombine,Dan Gohman2008-05-201-1/+28
| | | | | | now that instcombine also has ComputeNumSignBits. llvm-svn: 51350
* Fix typo.Matthijs Kooijman2008-05-201-1/+1
| | | | llvm-svn: 51303
* Teach instcombine 4 new xforms:Chris Lattner2008-05-201-3/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (add (sext x), cst) --> (sext (add x, cst')) (add (sext x), (sext y)) --> (sext (add int x, y)) (add double (sitofp x), fpcst) --> (sitofp (add int x, intcst)) (add double (sitofp x), (sitofp y)) --> (sitofp (add int x, y)) This generally reduces conversions. For example MiBench/telecomm-gsm gets these simplifications: HACK2: %tmp67.i142.i.i = sext i16 %tmp6.i141.i.i to i32 ; <i32> [#uses=1] %tmp23.i139.i.i = sext i16 %tmp2.i138.i.i to i32 ; <i32> [#uses=1] %tmp8.i143.i.i = add i32 %tmp67.i142.i.i, %tmp23.i139.i.i ; <i32> [#uses=3] HACK2: %tmp67.i121.i.i = sext i16 %tmp6.i120.i.i to i32 ; <i32> [#uses=1] %tmp23.i118.i.i = sext i16 %tmp2.i117.i.i to i32 ; <i32> [#uses=1] %tmp8.i122.i.i = add i32 %tmp67.i121.i.i, %tmp23.i118.i.i ; <i32> [#uses=3] HACK2: %tmp67.i.i190.i = sext i16 %tmp6.i.i189.i to i32 ; <i32> [#uses=1] %tmp23.i.i187.i = sext i16 %tmp2.i.i186.i to i32 ; <i32> [#uses=1] %tmp8.i.i191.i = add i32 %tmp67.i.i190.i, %tmp23.i.i187.i ; <i32> [#uses=3] HACK2: %tmp67.i173.i.i.i = sext i16 %tmp6.i172.i.i.i to i32 ; <i32> [#uses=1] %tmp23.i170.i.i.i = sext i16 %tmp2.i169.i.i.i to i32 ; <i32> [#uses=1] %tmp8.i174.i.i.i = add i32 %tmp67.i173.i.i.i, %tmp23.i170.i.i.i ; <i32> [#uses=3] HACK2: %tmp67.i152.i.i.i = sext i16 %tmp6.i151.i.i.i to i32 ; <i32> [#uses=1] %tmp23.i149.i.i.i = sext i16 %tmp2.i148.i.i.i to i32 ; <i32> [#uses=1] %tmp8.i153.i.i.i = add i32 %tmp67.i152.i.i.i, %tmp23.i149.i.i.i ; <i32> [#uses=3] HACK2: %tmp67.i.i.i.i = sext i16 %tmp6.i.i.i.i to i32 ; <i32> [#uses=1] %tmp23.i.i5.i.i = sext i16 %tmp2.i.i.i.i to i32 ; <i32> [#uses=1] %tmp8.i.i7.i.i = add i32 %tmp67.i.i.i.i, %tmp23.i.i5.i.i ; <i32> [#uses=3] This also fixes a bug in ComputeNumSignBits handling select and makes it more aggressive with and/or. llvm-svn: 51302
* fix two issues Neil noticed, thanks!Chris Lattner2008-05-201-5/+5
| | | | llvm-svn: 51296
* Refine the fix in r51169 to only apply when the operand val beingDan Gohman2008-05-201-3/+4
| | | | | | | | replaced is a PHI. This prevents it from inserting uses before defs in the case that it isn't a PHI and it depends on other instructions later in the block. This fixes the 447.dealII regression on x86-64. llvm-svn: 51292
* Make AssociativeOpt static.Dan Gohman2008-05-201-1/+1
| | | | llvm-svn: 51290
* Do not erase induction variable increment if it is used outside the loop.Devang Patel2008-05-191-4/+20
| | | | llvm-svn: 51280
* Add a ComputeNumSignBits function for use by instcombine, based on theDan Gohman2008-05-191-5/+149
| | | | | | code in SelectionDAG. llvm-svn: 51279
* switch to Type::getFPMantissaWidth instead of reinventing it.Chris Lattner2008-05-191-15/+3
| | | | llvm-svn: 51275
* minor cleanups, teach instcombine that sitofp/uitofp cannot Chris Lattner2008-05-191-3/+8
| | | | | | produce a negative zero. llvm-svn: 51272
* convert fptosi(sitofp x) -> x if the fp value has enough bits in its mantissaChris Lattner2008-05-191-9/+27
| | | | | | | to accurately represent the integer. This triggers 9 times in 471.omnetpp, though 8 of those seem to be inlined from the same place. llvm-svn: 51271
* Fold FP comparisons where one operand is converted from an integerChris Lattner2008-05-191-0/+160
| | | | | | | | | | | | | | | | | | | | type and the other operand is a constant into integer comparisons. This happens surprisingly frequently (e.g. 10 times in 471.omnetpp), which are things like this: %tmp8283 = sitofp i32 %tmp82 to double %tmp1013 = fcmp ult double %tmp8283, 0.0 Clearly comparing tmp82 against i32 0 is cheaper here. this also triggers 8 times in gobmk, including this one: %tmp375376 = sitofp i32 %tmp375 to double %tmp377 = fcmp ogt double %tmp375376, 8.150000e+01 which is comparing an integer against 81.5 :). llvm-svn: 51268
* remove debug outputChris Lattner2008-05-191-3/+1
| | | | llvm-svn: 51264
* be more aggressive about transforming add -> or when the operands have noChris Lattner2008-05-191-0/+19
| | | | | | | | | | | | | | | | | | | intersecting bits. This triggers all over the place, for example in lencode, with adds of stuff like: %tmp580 = mul i32 %tmp579, 2 %tmp582 = and i32 %b8, 1 and %tmp28 = shl i32 %abs.i, 1 %sign.0 = select i1 %tmp23, i32 1, i32 0 and %tmp344 = shl i32 %tmp343, 2 %tmp346 = and i32 %tmp96, 3 etc. llvm-svn: 51263
* Fix PR2341 - when the length is 4 use an i32 notDuncan Sands2008-05-191-8/+10
| | | | | | an i16! Cleaned up trailing whitespace while there. llvm-svn: 51240
OpenPOWER on IntegriCloud