summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify
Commit message (Collapse)AuthorAgeFilesLines
...
* An argument and a local identified object (eg. a noalias call) could turn outNick Lewycky2012-02-251-14/+24
| | | | | | | equal if both are null. In the test, scope type %t and global @y by adding a 'gep' prefix to them. llvm-svn: 151452
* Teach instsimplify to be more aggressive when analyzing comparisons of pointersNick Lewycky2012-02-251-0/+44
| | | | | | | 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-0/+10
| | | | | | 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-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+10
| | | | | | LHS->stripPointerCasts() != RHS->stripPointerCasts(). llvm-svn: 150863
* InstSimplify: Ignore pointer casts when constant folding compares between ↵Benjamin Kramer2012-02-161-0/+20
| | | | | | pointers. llvm-svn: 150690
* Replace all instances of dg.exp file with lit.local.cfg, since all tests are ↵Eli Bendersky2012-02-162-3/+1
| | | | | | | | 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. llvm-svn: 150664
* Fix PR11948: the result type of an icmp may be a vector of boolean -Duncan Sands2012-02-101-0/+7
| | | | | | don't assume it is a boolean. llvm-svn: 150247
* Revert commit 149912 (lattner) and add a testcase that shows the problem (whichDuncan Sands2012-02-101-0/+9
| | | | | | | | | | 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. llvm-svn: 150246
* Add support for vectors of pointers.Nadav Rotem2011-12-051-0/+8
| | | | llvm-svn: 145801
* Fix a crash in which a multiplication was being reported as being both negativeDuncan Sands2011-11-231-0/+17
| | | | | | | | 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). llvm-svn: 145104
* Fix code to match comment. Fixes PR11340, a regression from r143209.Eli Friedman2011-11-081-0/+10
| | | | llvm-svn: 144121
* Add tests for existing InstSimplify features.Dan Gohman2011-11-041-0/+21
| | | | llvm-svn: 143721
* Teach instsimplify to simplify calls to undef.Dan Gohman2011-11-041-0/+7
| | | | llvm-svn: 143719
* Reapply commit 143214 with a fix: m_ICmp doesn't match conditionsDuncan Sands2011-10-301-0/+18
| | | | | | | | | | | | 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-9/+0
| | | | llvm-svn: 143265
* The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false.Duncan Sands2011-10-281-0/+9
| | | | | | | | | 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
* A shift of a power of two is a power of two or zero.Duncan Sands2011-10-281-0/+10
| | | | | | For completeness - not spotted in the wild. llvm-svn: 143211
* Fold icmp ugt (udiv X, Y), X to false. Spotted by my super-optimizerDuncan Sands2011-10-281-0/+24
| | | | | | in 186.crafty. llvm-svn: 143209
* Reapply commit 143028 with a fix: the problem was casting a ConstantExpr MulDuncan Sands2011-10-272-0/+43
| | | | | | | | | | | 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
* Revert Duncan's r143028 expression folding which appears to be the culpritBob Wilson2011-10-271-31/+0
| | | | | | behind a compile failure on 483.xalancbmk. llvm-svn: 143102
* The maximum power of 2 dividing a power of 2 is itself. This occursDuncan Sands2011-10-261-0/+12
| | | | | | in 403.gcc and was spotted by my super-optimizer. llvm-svn: 143054
* My super-optimizer noticed that we weren't folding this expression toDuncan Sands2011-10-261-0/+31
| | | | | | true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref. llvm-svn: 143028
* InstSimplify: Don't try to replace an extractvalue/insertvalue pair with the ↵Benjamin Kramer2011-09-051-4/+11
| | | | | | | | 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/+22
| | | | | | up do-nothing exception handling code produced by dragonegg. llvm-svn: 139113
* Remove bogus test: for all possible inputs of %X, the 'sub nsw' is guaranteedNick Lewycky2011-07-191-11/+0
| | | | | | to perform a signed wrap. Don't rely on any particular handling of that case. llvm-svn: 135471
* Improve constant folding of undef for cmp and select operators.Dan Gohman2011-07-011-0/+28
| | | | llvm-svn: 134223
* Improve constant folding of undef for binary operators.Dan Gohman2011-07-011-0/+99
| | | | llvm-svn: 134221
* The comparision "max(x,y)==x" is equivalent to "x>=y". Since the max isDuncan Sands2011-05-071-0/+36
| | | | | | | 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
* Add variations on: max(x,y) >= min(x,z) folds to true. This isn't that common,Duncan Sands2011-05-041-0/+88
| | | | | | | | 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/+145
| | | | | | | | 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
* Move some rem transforms out of instcombine and into instsimplify.Duncan Sands2011-05-021-0/+17
| | | | | | | This automagically provides a transform noticed by my super-optimizer as occurring quite often: "rem x, (select cond, x, 1)" -> 0. llvm-svn: 130694
* Teach ComputeMaskedBits about sub nsw.Benjamin Kramer2011-03-121-0/+23
| | | | llvm-svn: 127548
* Teach ComputeMaskedBits about nsw on add. I don't think there's anything we canNick Lewycky2011-03-111-0/+10
| | | | | | | do with nuw here, but sub and mul should be given similar treatment. Fixes PR9343 #15! llvm-svn: 127463
* Fix mistyped CHECK lines.Benjamin Kramer2011-03-091-1/+1
| | | | llvm-svn: 127366
* Add another micro-optimization. Apologies for the lack of refactoring, but INick Lewycky2011-03-091-0/+8
| | | | | | | | | 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-0/+9
| | | | | | | | | 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-9/+0
| | | | llvm-svn: 127021
* Fold "icmp pred (srem X, Y), Y" like we do for urem. Handle signed comparisonsNick Lewycky2011-03-041-0/+18
| | | | | | | in the urem case, though not the other way around. This is enough to get #3 from PR9343! llvm-svn: 126991
* Teach instruction simplify to use constant ranges to solve problems of the formNick Lewycky2011-03-041-4/+76
| | | | | | | | | "icmp pred %X, CI" and a number of examples where "%X = binop %Y, CI2". Some of these cases (div and rem) used to make it through opt -O2, but the others are probably now making code elsewhere redundant (probably instcombine). llvm-svn: 126988
* Optimize "icmp pred (urem X, Y), Y" --> true/false depending on pred. There'sNick Lewycky2011-03-011-0/+16
| | | | | | | more work to do here, "icmp ult (urem X, 10), 11" doesn't optimize away yet. Fixes example 3 from PR9343! llvm-svn: 126741
* Teach instsimplify that X+Y>=X+Z is the same as Y>=Z if neither side overflows,Duncan Sands2011-02-131-0/+20
| | | | | | | | plus some variations of this. According to my auto-simplifier this occurs a lot but usually in combination with max/min idioms. Because max/min aren't handled yet this unfortunately doesn't have much effect in the testsuite. llvm-svn: 125462
* Teach instsimplify some tricks about exact/nuw/nsw shifts.Chris Lattner2011-02-091-0/+44
| | | | | | improve interfaces to instsimplify to take this info. llvm-svn: 125196
* teach instsimplify to transform (X / Y) * Y to XChris Lattner2011-02-061-0/+20
| | | | | | when the div is an exact udiv. llvm-svn: 124994
* rename test.Chris Lattner2011-02-061-0/+0
| | | | llvm-svn: 124993
* Improve threading of comparisons over select instructions (spotted by myDuncan Sands2011-02-031-0/+35
| | | | | | | | | | auto-simplifier). This has a big impact on Ada code, but not much else. Unfortunately the impact is mostly negative! This is due to PR9004 (aka SCCP failing to resolve conditional branch conditions in the destination blocks of the branch), in which simple correlated expressions are not resolved but complicated ones are, so simplifying has a bad effect! llvm-svn: 124788
* Reenable the transform "(X*Y)/Y->X" when the multiplication is known not toDuncan Sands2011-02-021-0/+4
| | | | | | | | overflow (nsw flag), which was disabled because it breaks 254.gap. I have informed the GAP authors of the mistake in their code, and arranged for the testsuite to use -fwrapv when compiling this benchmark. llvm-svn: 124746
* Have m_One also match constant vectors for which every element is 1.Duncan Sands2011-02-011-0/+8
| | | | llvm-svn: 124655
* Commit 124487 broke 254.gap. See if disabling the part that might be triggeredDuncan Sands2011-01-301-4/+0
| | | | | | by PR9088 fixes things. llvm-svn: 124561
* Transform (X/Y)*Y into X if the division is exact. Instcombine already ↵Duncan Sands2011-01-301-0/+18
| | | | | | | | | | | | knows how to do this and more, but would only do it if X/Y had only one use. Spotted as the most common missed simplification in SPEC by my auto-simplifier, now that it knows about nuw/nsw/exact flags. This removes a bunch of multiplications from 447.dealII and 483.xalancbmk. It also removes a lot from tramp3d-v4, which results in much more inlining. llvm-svn: 124560
OpenPOWER on IntegriCloud