summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor some methods to look through bitcasts and GEPs on pointers intoChandler Carruth2012-03-101-25/+3
| | | | | | | | | | a common collection of methods on Value, and share their implementation. We had two variations in two different places already, and I need the third variation for inline cost estimation. Reviewed by Duncan Sands on IRC, but further comments here welcome. llvm-svn: 152490
* Reinstate the optimization from r151449 with a fix to not turn 'gep %x' intoNick Lewycky2012-02-261-11/+51
| | | | | | 'gep null' when the icmp predicate is unsigned (or is signed without inbounds). llvm-svn: 151467
* Don't call dominates on unreachable instructions.Rafael Espindola2012-02-261-1/+2
| | | | llvm-svn: 151466
* Roll these back to r151448 until I figure out how they're breakingNick Lewycky2012-02-251-42/+10
| | | | | | MultiSource/Applications/lua. llvm-svn: 151463
* An argument and a local identified object (eg. a noalias call) could turn outNick Lewycky2012-02-251-12/+13
| | | | | | | equal if both are null. In the test, scope type %t and global @y by adding a 'gep' prefix to them. llvm-svn: 151452
* Fix five-letter typo in comment.Nick Lewycky2012-02-251-1/+1
| | | | llvm-svn: 151450
* Teach instsimplify to be more aggressive when analyzing comparisons of pointersNick Lewycky2012-02-251-10/+41
| | | | | | | by using llvm::isIdentifiedObject. Also teach it to handle GEPs that have the same base pointer and constant operands. Fixes PR11238! llvm-svn: 151449
* fix PR12075, a regression in a recent transform I added. In unreachable ↵Chris Lattner2012-02-241-4/+18
| | | | | | code, gep chains can be infinite. Just like "stripPointerCasts", use a set to keep track of visited instructions so we don't recurse infinitely. llvm-svn: 151383
* fold comparisons of gep'd alloca points with null to false,Chris Lattner2012-02-201-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implementing PR12013. We now compile the testcase to: __Z4testv: ## @_Z4testv ## BB#0: ## %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit pushq %rbx subq $64, %rsp leaq 32(%rsp), %rbx movq %rbx, (%rsp) leaq 64(%rsp), %rax movq %rax, 16(%rsp) movl $1, 32(%rsp) leaq 36(%rsp), %rax movq %rax, 8(%rsp) leaq (%rsp), %rdi callq __Z1gRN4llvm11SmallVectorIiLj8EEE movq (%rsp), %rdi cmpq %rbx, %rdi je LBB0_2 ## BB#1: callq _free LBB0_2: ## %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit addq $64, %rsp popq %rbx ret instead of: __Z4testv: ## @_Z4testv ## BB#0: pushq %rbx subq $64, %rsp xorl %eax, %eax leaq (%rsp), %rbx addq $32, %rbx movq %rbx, (%rsp) movq %rbx, 8(%rsp) leaq 64(%rsp), %rcx movq %rcx, 16(%rsp) je LBB0_2 ## BB#1: movl $1, 32(%rsp) movq %rbx, %rax LBB0_2: ## %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit addq $4, %rax movq %rax, 8(%rsp) leaq (%rsp), %rdi callq __Z1gRN4llvm11SmallVectorIiLj8EEE movq (%rsp), %rdi cmpq %rbx, %rdi je LBB0_4 ## BB#3: callq _free LBB0_4: ## %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit addq $64, %rsp popq %rbx ret This doesn't shrink clang noticably though. llvm-svn: 150944
* Fix a rather nasty regression from r150690: LHS != RHS does not imply ↵Eli Friedman2012-02-181-1/+2
| | | | | | LHS->stripPointerCasts() != RHS->stripPointerCasts(). llvm-svn: 150863
* Revert "InstSimplify: Strip pointer casts early."Benjamin Kramer2012-02-161-6/+5
| | | | | | | Turns out this isn't safe, because the code below depends on LHS and RHS having the same type. llvm-svn: 150695
* InstSimplify: Strip pointer casts early.Benjamin Kramer2012-02-161-5/+6
| | | | llvm-svn: 150694
* InstSimplify: Ignore pointer casts when constant folding compares between ↵Benjamin Kramer2012-02-161-2/+5
| | | | | | pointers. llvm-svn: 150690
* Fix PR11948: the result type of an icmp may be a vector of boolean -Duncan Sands2012-02-101-0/+5
| | | | | | don't assume it is a boolean. llvm-svn: 150247
* Convert assert(0) to llvm_unreachableCraig Topper2012-02-071-6/+3
| | | | llvm-svn: 149967
* PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use ↵Benjamin Kramer2012-01-011-10/+5
| | | | | | it to simplify a few matchers. llvm-svn: 147403
* Add support for vectors of pointers.Nadav Rotem2011-12-051-2/+5
| | | | llvm-svn: 145801
* Propagate TargetLibraryInfo throughout ConstantFolding.cpp and Chad Rosier2011-12-011-217/+307
| | | | | | | InstructionSimplify.cpp. Other fixups as needed. Part of rdar://10500969 llvm-svn: 145559
* Make use of "getScalarType()". No functionality change.Nick Lewycky2011-12-011-8/+3
| | | | llvm-svn: 145556
* Fix code to match comment. Fixes PR11340, a regression from r143209.Eli Friedman2011-11-081-1/+1
| | | | llvm-svn: 144121
* Teach instsimplify to simplify calls to undef.Dan Gohman2011-11-041-0/+11
| | | | llvm-svn: 143719
* Reapply commit 143214 with a fix: m_ICmp doesn't match conditionsDuncan Sands2011-10-301-29/+65
| | | | | | | | | | | | with the given predicate, it matches any condition and returns the predicate - d'oh! Original commit message: The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false. Spotted by my super-optimizer in 186.crafty and 450.soplex. We really need a proper infrastructure for handling generalizations of this kind of thing (which occur a lot), however this case is so simple that I decided to go ahead and implement it directly. llvm-svn: 143318
* Revert r143214; it's breaking a bunch of stuff.Eli Friedman2011-10-291-45/+29
| | | | llvm-svn: 143265
* The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false.Duncan Sands2011-10-281-29/+45
| | | | | | | | | Spotted by my super-optimizer in 186.crafty and 450.soplex. We really need a proper infrastructure for handling generalizations of this kind of thing (which occur a lot), however this case is so simple that I decided to go ahead and implement it directly. llvm-svn: 143214
* Fold icmp ugt (udiv X, Y), X to false. Spotted by my super-optimizerDuncan Sands2011-10-281-0/+12
| | | | | | in 186.crafty. llvm-svn: 143209
* Reapply commit 143028 with a fix: the problem was casting a ConstantExpr MulDuncan Sands2011-10-271-2/+3
| | | | | | | | | | | using BinaryOperator (which only works for instructions) when it should have been a cast to OverflowingBinaryOperator (which also works for constants). While there, correct a few other dubious looking uses of BinaryOperator. Thanks to Chad Rosier for the testcase. Original commit message: My super-optimizer noticed that we weren't folding this expression to true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref. llvm-svn: 143125
* The maximum power of 2 dividing a power of 2 is itself. This occursDuncan Sands2011-10-261-0/+9
| | | | | | in 403.gcc and was spotted by my super-optimizer. llvm-svn: 143054
* InstSimplify: Don't try to replace an extractvalue/insertvalue pair with the ↵Benjamin Kramer2011-09-051-1/+2
| | | | | | | | original value if types don't match. Fixes clang selfhost. llvm-svn: 139120
* Add some simple insertvalue simplifications, for the purpose of cleaningDuncan Sands2011-09-051-0/+36
| | | | | | up do-nothing exception handling code produced by dragonegg. llvm-svn: 139113
* Revert r137781; I agree with Duncan's comment that the situation in question ↵Eli Friedman2011-08-171-5/+4
| | | | | | is clearly impossible given the current structure of the code. llvm-svn: 137853
* Extend the undef ^ undef idiom once more. No testcase: I can't figure out ↵Eli Friedman2011-08-161-4/+5
| | | | | | how to actually trigger the codepath in question at the moment, but it might get exposed in the future. llvm-svn: 137781
* Fix what seems an obvious typo. Patch by Ivan Krasin. ProblemDuncan Sands2011-08-041-1/+1
| | | | | | reported at http://habrahabr.ru/blogs/compilers/125626/. llvm-svn: 136865
* Add helper function for getting true/false constants in a uniformDuncan Sands2011-07-261-34/+48
| | | | | | | way for i1 and vector of i1 types. Use these to make some code more self-documenting. llvm-svn: 136079
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-251-2/+1
| | | | llvm-svn: 135904
* Convert ConstantExpr::getGetElementPtr andJay Foad2011-07-211-3/+1
| | | | | | ConstantExpr::getInBoundsGetElementPtr to use ArrayRef. llvm-svn: 135673
* Convert SimplifyGEPInst to use ArrayRef.Jay Foad2011-07-191-8/+9
| | | | llvm-svn: 135482
* Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.Jay Foad2011-07-191-10/+10
| | | | llvm-svn: 135477
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-9/+9
| | | | llvm-svn: 135375
* Improve constant folding of undef for cmp and select operators.Dan Gohman2011-07-011-4/+4
| | | | llvm-svn: 134223
* The comparision "max(x,y)==x" is equivalent to "x>=y". Since the max isDuncan Sands2011-05-071-10/+56
| | | | | | | often expressed as "x >= y ? x : y", there is a good chance we can extract the existing "x >= y" from it and use that as a replacement for "max(x,y)==x". llvm-svn: 131049
* PR9838: Fix transform introduced in r127064 to not trigger when only one ↵Eli Friedman2011-05-051-1/+1
| | | | | | side of the icmp is an exact shift. llvm-svn: 130954
* Add variations on: max(x,y) >= min(x,z) folds to true. This isn't that common,Duncan Sands2011-05-041-2/+46
| | | | | | | | but according to my super-optimizer there are only two missed simplifications of -instsimplify kind when compiling bzip2, and this is one of them. It amuses me to have bzip2 be perfectly optimized as far as instsimplify goes! llvm-svn: 130840
* Implement some basic simplifications involving min/max, for exampleDuncan Sands2011-05-031-0/+118
| | | | | | | | max(a,b) >= a -> true. According to my super-optimizer, these are by far the most common simplifications (of the -instsimplify kind) that occur in the testsuite and aren't caught by -std-compile-opts. llvm-svn: 130780
* Fix PR9579: when simplifying a compare to "true" or "false", and it wasDuncan Sands2011-05-021-18/+22
| | | | | | a vector compare, generate a vector result rather than i1 (and crashing). llvm-svn: 130706
* Move some rem transforms out of instcombine and into instsimplify.Duncan Sands2011-05-021-0/+117
| | | | | | | This automagically provides a transform noticed by my super-optimizer as occurring quite often: "rem x, (select cond, x, 1)" -> 0. llvm-svn: 130694
* Don't include Operator.h from InstrTypes.h.Jay Foad2011-04-111-0/+1
| | | | llvm-svn: 129271
* Fix two cases I forgot to update when doing a mental "getSwappedPredicate".Nick Lewycky2011-03-091-2/+2
| | | | | | Thanks Duncan Sands! llvm-svn: 127323
* Add another micro-optimization. Apologies for the lack of refactoring, but INick Lewycky2011-03-091-2/+28
| | | | | | | | | gave up when I realized I couldn't come up with a good name for what the refactored function would be, to describe what it does. This is PR9343 test12, which is test3 with arguments reordered. Whoops! llvm-svn: 127318
* Thread comparisons over udiv/sdiv/ashr/lshr exact and lshr nuw/nsw wheneverNick Lewycky2011-03-051-1/+33
| | | | | | | | | possible. This goes into instcombine and instsimplify because instsimplify doesn't need to check hasOneUse since it returns (almost exclusively) constants. This fixes PR9343 #4 #5 and #8! llvm-svn: 127064
* Revert broken srem logic from r126991.Nick Lewycky2011-03-041-15/+0
| | | | llvm-svn: 127021
OpenPOWER on IntegriCloud