summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/Reassociate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix reassociate to use a worklist instead of recursing when newDan Gohman2011-04-121-59/+67
| | | | | | | | | reassociation opportunities are exposed. This fixes a bug where the nested reassociation expects to be the IR to be consistent, but it isn't, because the outer reassociation has disconnected some of the operands. rdar://9167457 llvm-svn: 129324
* 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
* fix PR9215, preventing -reassociate from clearing nsw/nuw whenChris Lattner2011-02-171-3/+4
| | | | | | it swaps the LHS/RHS of a single binop. llvm-svn: 125700
* Fix reassociate to clear optional flags, such as nsw.Dan Gohman2011-02-021-0/+16
| | | | llvm-svn: 124712
* 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. llvm-svn: 124287
* Get rid of static constructors for pass registration. Instead, every pass ↵Owen Anderson2010-10-191-1/+3
| | | | | | | | | | | | | | | | | exposes an initializeMyPassFunction(), which must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize the pass's dependencies. Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h before parsing commandline arguments. I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass registration/creation, please send the testcase to me directly. llvm-svn: 116820
* Now with fewer extraneous semicolons!Owen Anderson2010-10-071-1/+1
| | | | llvm-svn: 115996
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-061-1/+1
| | | | llvm-svn: 110460
* Revert r110396 to fix buildbots.Owen Anderson2010-08-061-1/+1
| | | | llvm-svn: 110410
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-051-1/+1
| | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. llvm-svn: 110396
* Fix batch of converting RegisterPass<> to INTIALIZE_PASS().Owen Anderson2010-07-211-1/+2
| | | | llvm-svn: 109045
* cache dereferenced iteratorsGabor Greif2010-07-121-2/+3
| | | | llvm-svn: 108138
* fix a nice subtle reassociate bug which would only occurChris Lattner2010-03-051-5/+21
| | | | | | | in a very specific use pattern embodied in the carefully reduced testcase. llvm-svn: 97794
* There are two ways of checking for a given type, for example isa<PointerType>(T)Duncan Sands2010-02-161-1/+1
| | | | | | | and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. llvm-svn: 96344
* Uniformize the names of type predicates: rather than having isFloatTy andDuncan Sands2010-02-151-3/+3
| | | | | | isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! llvm-svn: 96223
* Fix "the the" and similar typos.Dan Gohman2010-02-101-2/+2
| | | | llvm-svn: 95781
* Do not reassociate expressions with i1 type. SimplifyCFG converts someBob Wilson2010-02-041-0/+9
| | | | | | | | | | short-circuited conditions to AND/OR expressions, and those expressions are often converted back to a short-circuited form in code gen. The original source order may have been optimized to take advantage of the expected values, and if we reassociate them, we change the order and subvert that optimization. Radar 7497329. llvm-svn: 95333
* only factor from expressions whose uses are empty and whoseChris Lattner2010-01-091-0/+5
| | | | | | base is the right expression type. This fixes PR5981. llvm-svn: 93045
* Suppress an unused variable warning when assertions are off;Duncan Sands2010-01-081-2/+3
| | | | | | remove some trailing whitespace while there. llvm-svn: 93008
* fix an infinite loop in reassociate building emacs.Chris Lattner2010-01-051-0/+4
| | | | llvm-svn: 92679
* Change errs() to dbgs().David Greene2010-01-051-15/+15
| | | | llvm-svn: 92617
* theoretically the negate we find could be in a different function, checkChris Lattner2010-01-021-0/+4
| | | | | | for this case. llvm-svn: 92425
* When factoring multiply expressions across adds, factor both Chris Lattner2010-01-011-21/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | positive and negative forms of constants together. This allows us to compile: int foo(int x, int y) { return (x-y) + (x-y) + (x-y); } into: _foo: ## @foo subl %esi, %edi leal (%rdi,%rdi,2), %eax ret instead of (where the 3 and -3 were not factored): _foo: imull $-3, 8(%esp), %ecx imull $3, 4(%esp), %eax addl %ecx, %eax ret this started out as: movl 12(%ebp), %ecx imull $3, 8(%ebp), %eax subl %ecx, %eax subl %ecx, %eax subl %ecx, %eax ret This comes from PR5359. llvm-svn: 92381
* clean up some comments.Chris Lattner2010-01-011-13/+13
| | | | llvm-svn: 92377
* switch from std::map to DenseMap for rank data structures.Chris Lattner2010-01-011-13/+13
| | | | llvm-svn: 92375
* reuse negates where possible instead of always creating them from scratch.Chris Lattner2009-12-311-1/+30
| | | | | | | | | | | | | | | | | | | | | This allows us to optimize test12 into: define i32 @test12(i32 %X) { %factor = mul i32 %X, -3 ; <i32> [#uses=1] %Z = add i32 %factor, 6 ; <i32> [#uses=1] ret i32 %Z } instead of: define i32 @test12(i32 %X) { %Y = sub i32 6, %X ; <i32> [#uses=1] %C = sub i32 %Y, %X ; <i32> [#uses=1] %Z = sub i32 %C, %X ; <i32> [#uses=1] ret i32 %Z } llvm-svn: 92373
* we don't need a smallptrset to detect duplicates, the values areChris Lattner2009-12-311-27/+27
| | | | | | sorted, so we can just do a linear scan. llvm-svn: 92372
* make reassociate more careful about not leaving around dead mul'sChris Lattner2009-12-311-1/+7
| | | | llvm-svn: 92370
* remove debugChris Lattner2009-12-311-1/+1
| | | | llvm-svn: 92369
* teach reassociate to factor x+x+x -> x*3. While I'm at it,Chris Lattner2009-12-311-22/+70
| | | | | | fix RemoveDeadBinaryOp to actually do something. llvm-svn: 92368
* change reassociate to use SmallVector for its key datastructuresChris Lattner2009-12-311-15/+18
| | | | | | instead of std::vector. llvm-svn: 92366
* change an if to an assert, fix comment.Chris Lattner2009-12-311-4/+4
| | | | llvm-svn: 92364
* move the rest of the add optimization code out to OptimizeAdd,Chris Lattner2009-12-311-93/+94
| | | | | | improve some comments, simplify a bit of code. llvm-svn: 92363
* factor statistic updating better.Chris Lattner2009-12-311-19/+9
| | | | llvm-svn: 92362
* simple fix for an incorrect factoring which causes aChris Lattner2009-12-311-0/+7
| | | | | | miscompilation, PR5458. llvm-svn: 92354
* factor code out into helper functions.Chris Lattner2009-12-311-88/+109
| | | | llvm-svn: 92347
* switch some std::vector's to smallvector. Reduce nesting.Chris Lattner2009-12-311-54/+57
| | | | llvm-svn: 92346
* use more modern datastructures.Chris Lattner2009-12-311-4/+5
| | | | llvm-svn: 92344
* clean up -debug output.Chris Lattner2009-12-311-3/+4
| | | | llvm-svn: 92343
* Remove LLVMContext from reassociate. It was threaded through every function butNick Lewycky2009-11-141-22/+14
| | | | | | ultimately never used. llvm-svn: 88763
* Make changes to rev 84292 as requested by Chris Lattner.Victor Hernandez2009-10-211-2/+0
| | | | | | | Most changes are cleanup, but there is 1 correctness fix: I fixed InstCombine so that the icmp is removed only if the malloc call is removed (which requires explicit removal because the Worklist won't DCE any calls since they can have side-effects). llvm-svn: 84772
* Remove MallocInst from LLVM Instructions.Victor Hernandez2009-10-171-1/+1
| | | | llvm-svn: 84299
* Autoupgrade malloc insts to malloc calls.Victor Hernandez2009-10-171-1/+2
| | | | | | | | Update testcases that rely on malloc insts being present. Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step. llvm-svn: 84292
* calls are already unmovable, malloc doesn't need a special case.Chris Lattner2009-09-271-2/+1
| | | | llvm-svn: 82933
* Enhance transform passes so that they apply the same tranforms to malloc ↵Victor Hernandez2009-09-181-1/+2
| | | | | | | | calls as to MallocInst. Reviewed by Dan Gohman. llvm-svn: 82300
* eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861Chris Lattner2009-09-021-3/+2
| | | | llvm-svn: 80766
* remove the std::ostream version of module and type printing.Chris Lattner2009-08-231-3/+3
| | | | llvm-svn: 79823
* eliminate the "Value" printing methods that print to a std::ostream.Chris Lattner2009-08-231-13/+14
| | | | | | This required converting a bunch of stuff off DOUT and other cleanups. llvm-svn: 79819
* Fix debug output to include a newline after printing a Value, nowDan Gohman2009-08-171-7/+7
| | | | | | that Value's operator<< doesn't include one. llvm-svn: 79240
OpenPOWER on IntegriCloud