summaryrefslogtreecommitdiff
path: root/test/Transforms/InstSimplify
Commit message (Collapse)AuthorAge
* ConstantFolding: ComputeMaskedBits wants the scalar size for vectors.Benjamin Kramer2013-04-19
| | | | | | Fixes PR15791. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179859 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing colons to check lines.Benjamin Kramer2013-04-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179277 91177308-0d34-0410-b5e6-96231b3b80d8
* Check whether a pointer is non-null (isKnownNonNull) in isKnownNonZero.Manman Ren2013-03-18
| | | | | | | | | This handles the case where we have an inbounds GEP with alloca as the pointer. This fixes the regression in PR12750 and rdar://13286434. Note that we can also fix this by handling some GEP cases in isKnownNonNull. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177321 91177308-0d34-0410-b5e6-96231b3b80d8
* [SimplifyLibCalls] Library call simplification doen't work if the call site Chad Rosier2013-02-08
| | | | | | | | isn't using the default calling convention. However, if the transformation is from a call to inline IR, then the calling convention doesn't matter. rdar://13157990 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174724 91177308-0d34-0410-b5e6-96231b3b80d8
* Identify and simplify idempotent intrinsics. Test case included.Michael Ilseman2013-02-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174650 91177308-0d34-0410-b5e6-96231b3b80d8
* ConstantFolding: Fix a crash when encoutering a truncating inttoptr.Benjamin Kramer2013-02-05
| | | | | | This was introduced in r173293. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174424 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a testcase for some past-the-end address subtleties.Dan Gohman2013-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174210 91177308-0d34-0410-b5e6-96231b3b80d8
* InstSimplify: stripAndComputeConstantOffsets can be called with vectors of ↵Benjamin Kramer2013-02-01
| | | | | | | | | | pointers too. Prepare it for vectors of pointers and handle simple cases. We don't handle complicated cases because accumulateConstantOffset bails on pointer vectors. Fixes selfhost on i386. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174179 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite instsimplify's handling if icmp on pointer values to remove theDan Gohman2013-02-01
| | | | | | | | | | | | | remaining use of AliasAnalysis concepts such as isIdentifiedObject to prove pointer inequality. @external_compare in test/Transforms/InstSimplify/compare.ll shows a simple case where a noalias argument can be equal to a global variable address, and while AliasAnalysis can get away with saying that these pointers don't alias, instsimplify cannot say that they are not equal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174122 91177308-0d34-0410-b5e6-96231b3b80d8
* An alloca can be equal to an argument. It can't *alias* an alloca, but it couldDan Gohman2013-01-31
| | | | | | | | be equal, since there's nothing preventing a caller from correctly predicting the stack location of an alloca. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174119 91177308-0d34-0410-b5e6-96231b3b80d8
* Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ↵Dmitri Gribenko2012-12-30
| | | | | | | | | ModuleID This is done to avoid odd test failures, like the one fixed in r171243. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171250 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instsimplify to use the constant folder where appropriate forChandler Carruth2012-12-28
| | | | | | | | constant folding calls. Add the initial tests for this which show that now instsimplify can simplify blindingly obvious code patterns expressed with both intrinsics and library calls. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171194 91177308-0d34-0410-b5e6-96231b3b80d8
* Added a slew of SimplifyInstruction floating-point optimizations, many of ↵Michael Ilseman2012-12-12
| | | | | | | | | | | | | | | | | | which take advantage of fast-math flags. Test cases included. fsub X, +0 ==> X fsub X, -0 ==> X, when we know X is not -0 fsub +/-0.0, (fsub -0.0, X) ==> X fsub nsz +/-0.0, (fsub +/-0.0, X) ==> X fsub nnan ninf X, X ==> 0.0 fadd nsz X, 0 ==> X fadd [nnan ninf] X, (fsub [nnan ninf] 0, X) ==> 0 where nnan and ninf have to occur at least once somewhere in this expression fmul X, 1.0 ==> X git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169940 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support to ValueTracking for determining that a pointer is non-nullChandler Carruth2012-12-07
| | | | | | | | | | | | | | | | | | | | | | | by virtue of inbounds GEPs that preclude a null pointer. This is a very common pattern in the code generated by std::vector and other standard library routines which use allocators that test for null pervasively. This is one step closer to teaching Clang+LLVM to be able to produce an empty function for: void f() { std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); } Which is related to getting them to completely fold SmallVector push_back sequences into constants when inlining and other optimizations make that a possibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169573 91177308-0d34-0410-b5e6-96231b3b80d8
* Fast-math test for SimplifyInstruction: fold multiply by 0Michael Ilseman2012-11-27
| | | | | | | | Applied the patch, rather than committing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168656 91177308-0d34-0410-b5e6-96231b3b80d8
* InstructionSimplify should be able to simplify A+B==B+A to 'true'Duncan Sands2012-11-16
| | | | | | | but wasn't due to the same logic bug that caused PR14361. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168186 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r153521 as it's causing large regressions on the nightly testers.Chad Rosier2012-03-28
| | | | | | | | | Original commit message for r153521 (aka r153423): Use the new range metadata in computeMaskedBits and add a new optimization to instruction simplify that lets us remove an and when loding a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153587 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r153423; the original commit was fine. The failing test, distray, had Chad Rosier2012-03-27
| | | | | | | | | | | undefined behavior, which Rafael was kind enough to fix. Original commit message for r153423: Use the new range metadata in computeMaskedBits and add a new optimization to instruction simplify that lets us remove an and when loding a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153521 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r153423 as this is causing failures on our internal nightly testers.Chad Rosier2012-03-26
| | | | | | | | Original commit message: Use the new range metadata in computeMaskedBits and add a new optimization to instruction simplify that lets us remove an and when loading a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153452 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new range metadata in computeMaskedBits and add a new optimization toRafael Espindola2012-03-26
| | | | | | instruction simplify that lets us remove an and when loding a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153423 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instsimplify how to simplify comparisons of pointers which areChandler Carruth2012-03-25
| | | | | | | constant-offsets of a common base using the generic GEP-walking logic I added for computing pointer differences in the same situation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153419 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the pointer-difference simplification logic to only work withChandler Carruth2012-03-25
| | | | | | | | | | | | inbounds GEPs. This isn't really necessary for simplifying pointer differences, but I'm planning to re-use the same code to simplify pointer comparisons where it is necessary. Since real code almost exclusively uses inbounds GEPs, it doesn't seem worth it to support the extra complexity of turning it on and off. If anyone would like that back, feel free to shout. Note that instcombine will still catch any of these patterns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153418 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize the "trunc(ptrtoint(x)) - trunc(ptrtoint(y)) ->Duncan Sands2012-03-13
| | | | | | | trunc(ptrtoint(x-y))" optimization introduced by Chandler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152626 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instsimplify how to constant fold pointer differences.Chandler Carruth2012-03-12
| | | | | | | | | | | | | | | | | | | Typically instcombine has handled this, but pointer differences show up in several contexts where we would like to get constant folding, and cannot afford to run instcombine. Specifically, I'm working on improving the constant folding of arguments used in inline cost analysis with instsimplify. Doing this in instsimplify implies some algorithm changes. We have to handle multiple layers of all-constant GEPs because instsimplify cannot fold them into a single GEP the way instcombine can. Also, we're only interested in all-constant GEPs. The result is that this doesn't really replace the instcombine logic, it's just complimentary and focused on constant folding. Reviewed on IRC by Benjamin Kramer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152555 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure we don't return bits outside the mask in ComputeMaskedBits. PR12189.Eli Friedman2012-03-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152066 91177308-0d34-0410-b5e6-96231b3b80d8
* Reinstate the optimization from r151449 with a fix to not turn 'gep %x' intoNick Lewycky2012-02-26
| | | | | | | 'gep null' when the icmp predicate is unsigned (or is signed without inbounds). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151467 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll these back to r151448 until I figure out how they're breakingNick Lewycky2012-02-25
| | | | | | | MultiSource/Applications/lua. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151463 91177308-0d34-0410-b5e6-96231b3b80d8
* An argument and a local identified object (eg. a noalias call) could turn outNick Lewycky2012-02-25
| | | | | | | | equal if both are null. In the test, scope type %t and global @y by adding a 'gep' prefix to them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151452 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instsimplify to be more aggressive when analyzing comparisons of pointersNick Lewycky2012-02-25
| | | | | | | | by using llvm::isIdentifiedObject. Also teach it to handle GEPs that have the same base pointer and constant operands. Fixes PR11238! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151449 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR12075, a regression in a recent transform I added. In unreachable ↵Chris Lattner2012-02-24
| | | | | | code, gep chains can be infinite. Just like "stripPointerCasts", use a set to keep track of visited instructions so we don't recurse infinitely. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151383 91177308-0d34-0410-b5e6-96231b3b80d8
* fold comparisons of gep'd alloca points with null to false,Chris Lattner2012-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150944 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a rather nasty regression from r150690: LHS != RHS does not imply ↵Eli Friedman2012-02-18
| | | | | | LHS->stripPointerCasts() != RHS->stripPointerCasts(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150863 91177308-0d34-0410-b5e6-96231b3b80d8
* InstSimplify: Ignore pointer casts when constant folding compares between ↵Benjamin Kramer2012-02-16
| | | | | | pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150690 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace all instances of dg.exp file with lit.local.cfg, since all tests are ↵Eli Bendersky2012-02-16
| | | | | | | | | | | run with LIT now and now Dejagnu. dg.exp is no longer needed. Patch reviewed by Daniel Dunbar. It will be followed by additional cleanup patches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150664 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR11948: the result type of an icmp may be a vector of boolean -Duncan Sands2012-02-10
| | | | | | | don't assume it is a boolean. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150247 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert commit 149912 (lattner) and add a testcase that shows the problem (whichDuncan Sands2012-02-10
| | | | | | | | | | | is that patterns no longer match for vectors of booleans, because you only get ConstantDataVector when the vector element type is i8, i16, etc, not when it is i1). Original commit message: Remove some dead code and tidy things up now that vectors use ConstantDataVector instead of always using ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150246 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for vectors of pointers.Nadav Rotem2011-12-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145801 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crash in which a multiplication was being reported as being both negativeDuncan Sands2011-11-23
| | | | | | | | | and positive: positive, because it could be directly computed to be positive; negative, because the nsw flags means it is either negative or undefined (the multiplication always overflowed). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145104 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix code to match comment. Fixes PR11340, a regression from r143209.Eli Friedman2011-11-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144121 91177308-0d34-0410-b5e6-96231b3b80d8
* Add tests for existing InstSimplify features.Dan Gohman2011-11-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143721 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instsimplify to simplify calls to undef.Dan Gohman2011-11-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143719 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply commit 143214 with a fix: m_ICmp doesn't match conditionsDuncan Sands2011-10-30
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143318 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r143214; it's breaking a bunch of stuff.Eli Friedman2011-10-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143265 91177308-0d34-0410-b5e6-96231b3b80d8
* The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false.Duncan Sands2011-10-28
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143214 91177308-0d34-0410-b5e6-96231b3b80d8
* A shift of a power of two is a power of two or zero.Duncan Sands2011-10-28
| | | | | | | For completeness - not spotted in the wild. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143211 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold icmp ugt (udiv X, Y), X to false. Spotted by my super-optimizerDuncan Sands2011-10-28
| | | | | | | in 186.crafty. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143209 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply commit 143028 with a fix: the problem was casting a ConstantExpr MulDuncan Sands2011-10-27
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143125 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert Duncan's r143028 expression folding which appears to be the culpritBob Wilson2011-10-27
| | | | | | behind a compile failure on 483.xalancbmk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143102 91177308-0d34-0410-b5e6-96231b3b80d8
* The maximum power of 2 dividing a power of 2 is itself. This occursDuncan Sands2011-10-26
| | | | | | | in 403.gcc and was spotted by my super-optimizer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143054 91177308-0d34-0410-b5e6-96231b3b80d8
* My super-optimizer noticed that we weren't folding this expression toDuncan Sands2011-10-26
| | | | | | | true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143028 91177308-0d34-0410-b5e6-96231b3b80d8