aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove MallocInst from LLVM Instructions.Victor Hernandez2009-10-171-30/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84299 91177308-0d34-0410-b5e6-96231b3b80d8
* only try to fold constantexpr operands when the worklist is first populated, Chris Lattner2009-10-151-15/+30
| | | | | | | | | | don't bother every time going around the main worklist. This speeds up a release-asserts opt -std-compile-opts on 403.gcc by about 4% (1.5s). It seems to speed up the most expensive instances of instcombine by ~10%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84171 91177308-0d34-0410-b5e6-96231b3b80d8
* don't bother calling ConstantFoldInstruction unless there is a use of theChris Lattner2009-10-151-22/+25
| | | | | | | | | | | instruction (which disqualifies stores, unreachable, etc) and at least the first operand is a constant. This filters out a lot of obvious cases that can't be folded. Also, switch the IRBuilder to a TargetFolder, which tries harder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84170 91177308-0d34-0410-b5e6-96231b3b80d8
* Use isVoidTy()Devang Patel2009-10-141-7/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84118 91177308-0d34-0410-b5e6-96231b3b80d8
* make instcombine's instruction sinking more aggressive in theChris Lattner2009-10-141-3/+10
| | | | | | | presence of PHI nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84103 91177308-0d34-0410-b5e6-96231b3b80d8
* Check void type before using RAUWd.Devang Patel2009-10-131-4/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84049 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not check use_empty() before replaceAllUsesWith(). This gives ↵Devang Patel2009-10-131-9/+6
| | | | | | ValueHandles a chance to get properly updated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84033 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix warning.Dale Johannesen2009-10-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83870 91177308-0d34-0410-b5e6-96231b3b80d8
* populate instcombine's initial worklist more carefully, causingChris Lattner2009-10-121-18/+26
| | | | | | | | | | | | it to visit instructions from the start of the function to the end of the function in the first path. This greatly speeds up some pathological cases (e.g. PR5150). Try #3, this time with some unneeded debug info stuff removed which was causing dead pointers to be added to the worklist. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83818 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r83814 for now, it is making the llvm-gcc bootstrap unhappy.Chris Lattner2009-10-111-26/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83817 91177308-0d34-0410-b5e6-96231b3b80d8
* populate instcombine's initial worklist more carefully, causingChris Lattner2009-10-111-1/+26
| | | | | | | | | | it to visit instructions from the start of the function to the end of the function in the first path. This greatly speeds up some pathological cases (e.g. PR5150). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83814 91177308-0d34-0410-b5e6-96231b3b80d8
* remove some harmful code that would turn an insertelement on an undefChris Lattner2009-10-111-22/+0
| | | | | | | | | | | | into a shuffle even if it was used by another insertelement. If the visitation order of instcombine was wrong, this would turn a chain of insertelements into a chain of shufflevectors, which was quite painful. Since CollectShuffleElements handles these cases, the code can just be nuked. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83810 91177308-0d34-0410-b5e6-96231b3b80d8
* teach instcombine to simplify xor's harder, catching theChris Lattner2009-10-111-0/+27
| | | | | | | new testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83799 91177308-0d34-0410-b5e6-96231b3b80d8
* cleanupsChris Lattner2009-10-111-20/+18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83797 91177308-0d34-0410-b5e6-96231b3b80d8
* cleanup, no functionality change.Chris Lattner2009-10-111-34/+33
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83795 91177308-0d34-0410-b5e6-96231b3b80d8
* generalize a transformation even more: we don't care whether theChris Lattner2009-10-111-12/+10
| | | | | | | | | | input the the mul is a zext from bool, just that it is all zeros other than the low bit. This fixes some phase ordering issues that would cause us to miss some xforms in mul.ll when the worklist is visited differently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83794 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify a transformation by making it more general.Chris Lattner2009-10-111-32/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83792 91177308-0d34-0410-b5e6-96231b3b80d8
* temporarily revert previous patchChris Lattner2009-10-111-14/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83791 91177308-0d34-0410-b5e6-96231b3b80d8
* populate instcombine's initial worklist more carefully, causingChris Lattner2009-10-111-1/+14
| | | | | | | | | it to visit instructions from the start of the function to the end of the function in the first path. This greatly speeds up some pathological cases (e.g. PR5150). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83790 91177308-0d34-0410-b5e6-96231b3b80d8
* implement rdar://7293527, a trivial instcombine that llvm-gccChris Lattner2009-10-111-1/+12
| | | | | | | | gets but clang doesn't, because it is implemented in GCC's fold routine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83761 91177308-0d34-0410-b5e6-96231b3b80d8
* In instcombine's debug output, avoid printing ADD for instructions that areJeffrey Yasskin2009-10-081-3/+5
| | | | | | | | already on the worklist, and print Visited when an instruction is about to be visited. Net, on one input, this reduced the output size by at least 9x. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83510 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce and use convenience methods for getting pointer typesDuncan Sands2009-10-061-3/+3
| | | | | | | | where the element is of a basic builtin type. For example, to get an i8* use getInt8PtrTy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83379 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an unnnecessary LLVMContext argument inDan Gohman2009-10-051-2/+1
| | | | | | | ConstantFoldLoadThroughGEPConstantExpr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83311 91177308-0d34-0410-b5e6-96231b3b80d8
* Use Use::operator= instead of Use::set, for consistency.Dan Gohman2009-10-051-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83310 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine shouldn't delete all null checks for mallocs.Chris Lattner2009-10-051-2/+2
| | | | | | | This fixes PR5130. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83290 91177308-0d34-0410-b5e6-96231b3b80d8
* The select instruction is not neccesarily in the same block as theChris Lattner2009-09-281-2/+3
| | | | | | | | | phi nodes. Make sure to phi translate from the right block. This fixes a llvm-building-llvm failure on GVN-PRE.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82970 91177308-0d34-0410-b5e6-96231b3b80d8
* The bitcast case is not needed here: instcombine turns icmp(bitcast(x), ↵Chris Lattner2009-09-271-24/+7
| | | | | | null) -> icmp(x, null) already. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82935 91177308-0d34-0410-b5e6-96231b3b80d8
* allow pushing icmps through phis with multiple uses and across critical edges.Chris Lattner2009-09-271-8/+23
| | | | | | | These are important to push up to encourage jump threading. This shrinks 176.gcc a bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82923 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance the previous fix for PR4895 to allow more values than justChris Lattner2009-09-271-13/+26
| | | | | | | | simple constants for the true/false value of the select. We now do phi translation etc. This really fixes PR4895 :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82917 91177308-0d34-0410-b5e6-96231b3b80d8
* implement PR4895, by making FoldOpIntoPhi handle select conditionsChris Lattner2009-09-271-11/+42
| | | | | | | | | | | that are phi nodes. Also tighten up FoldOpIntoPhi to treat constantexpr operands to phis just like other variables, avoiding moving constantexpr computations around. Patch by Daniel Dunbar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82913 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance transform passes so that they apply the same tranforms to malloc ↵Victor Hernandez2009-09-181-8/+54
| | | | | | | | | | calls as to MallocInst. Reviewed by Dan Gohman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82300 91177308-0d34-0410-b5e6-96231b3b80d8
* Change FoldPHIArgBinOpIntoPHI to decline folding if it would introduce twoDan Gohman2009-09-161-7/+13
| | | | | | | | | phis, similar to the FoldPHIArgGEPIntoPHI change. Also, delete some comments that don't reflect the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82053 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't sink gep operators through phi nodes if the result would requireDan Gohman2009-09-161-1/+14
| | | | | | | | | more than one phi, since that leads to higher register pressure on entry to the phi. This is especially problematic when the phi is in a loop header, as it increases register pressure throughout the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81993 91177308-0d34-0410-b5e6-96231b3b80d8
* remove an extremely dubious instcombine transformation ofChris Lattner2009-09-081-42/+14
| | | | | | | extractelement(load). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81239 91177308-0d34-0410-b5e6-96231b3b80d8
* remove a turdChris Lattner2009-09-081-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81186 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine transforms vector loads that are only used byChris Lattner2009-09-081-22/+27
| | | | | | | | | | | | | | | | | | | | | | extractelement operations into a bitcast of the pointer, then a gep, then a scalar load. Disable this when the vector only has one element, because it leads to infinite loops in instcombine (PR4908). This transformation seems like a really bad idea to me, as it will likely disable CSE of vector load/stores etc and can be better done in the code generator when profitable. This goes all the way back to the first days of packed types, r25299 specifically. I'll let those people who care about the performance of vector code decide what to do with this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81185 91177308-0d34-0410-b5e6-96231b3b80d8
* Reappy r80998, now that the GlobalOpt bug that it exposed on MiniSAT is fixed.Dan Gohman2009-09-071-41/+32
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81172 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a possible crash call setIsInBounds.Daniel Dunbar2009-09-061-2/+2
| | | | | | | | - I think there are more instances of this, but I think they are fixed in Dan's incoming patch. This one was preventing me from doing a bugpoint reduction though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81103 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", thisDaniel Dunbar2009-09-061-33/+43
| | | | | | breaks MiniSAT on x86_64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81098 91177308-0d34-0410-b5e6-96231b3b80d8
* Include optional subclass flags, such as inbounds, nsw, etc., in theDan Gohman2009-09-041-43/+33
| | | | | | | | | | | | | | | | | | Constant uniquing tables. This allows distinct ConstantExpr objects with the same operation and different flags. Even though a ConstantExpr "a + b" is either always overflowing or never overflowing (due to being a ConstantExpr), it's still necessary to be able to represent it both with and without overflow flags at the same time within the IR, because the safety of the flag may depend on the context of the use. If the constant really does overflow, it wouldn't ever be safe to use with the flag set, however the use may be in code that is never actually executed. This also makes it possible to merge all the flags tests into a single test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80998 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861Chris Lattner2009-09-021-4/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80766 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR4837, some bugs folding vector compares. TheseChris Lattner2009-09-021-7/+7
| | | | | | | return a vector of i1, not i1 itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80761 91177308-0d34-0410-b5e6-96231b3b80d8
* fix some cases where instcombine would change hte IR but not return trueChris Lattner2009-08-311-8/+10
| | | | | | | from runOnFunction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80562 91177308-0d34-0410-b5e6-96231b3b80d8
* improve -debug output, so that -debug is more likely to print whenChris Lattner2009-08-311-3/+6
| | | | | | | instcombine is changing stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80538 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bug I introduced with my 'instcombine builder' refactoring Chris Lattner2009-08-311-2/+6
| | | | | | | | | changes: SimplifyDemandedBits can't use the builder yet because it has the wrong insertion point. This fixes a crash building MultiSource/Benchmarks/PAQ8p git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80537 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR4748: don't fold gep(bitcast(x)) into bitcast(gep) when x Chris Lattner2009-08-301-0/+7
| | | | | | | | | | is itself a bitcast. Since we have gep(bitcast(bitcast(y))) in this case, just wait for the two bitcasts to get zapped. This prevents instcombine from confusing some aliasing stuff, and allows it to directly eliminate the load in the testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80508 91177308-0d34-0410-b5e6-96231b3b80d8
* misc cleanupChris Lattner2009-08-301-13/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80507 91177308-0d34-0410-b5e6-96231b3b80d8
* add getPointerAddressSpace() to GEP instruction, use the methodChris Lattner2009-08-301-6/+4
| | | | | | | in a few scalar xforms to simplify things. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80506 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate InsertCastBefore, use the builder instead.Chris Lattner2009-08-301-50/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80505 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate InsertBitCastBefore, just use the builder instead.Chris Lattner2009-08-301-27/+24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80504 91177308-0d34-0410-b5e6-96231b3b80d8