summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Recognize and simplifyAnders Carlsson2011-01-301-1/+11
| | | | | | | (A+B) == A -> B == 0 A == (A+B) -> B == 0 llvm-svn: 124567
* At -O123 the early-cse pass is run before instcombine has run. According to myDuncan Sands2011-01-201-32/+11
| | | | | | | | | | | | | | | | auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0. This patch adds this transform and some related logic to InstructionSimplify and removes some of the logic from instcombine (unfortunately not all because there are several situations in which instcombine can improve things by making new instructions, whereas instsimplify is not allowed to do this). At -O2 this often results in more than 15% more simplifications by early-cse, and results in hundreds of lines of bitcode being eliminated from the testsuite. I did see some small negative effects in the testsuite, for example a few additional instructions in three programs. One program, 483.xalancbmk, got an additional 35 instructions, which seems to be due to a function getting an additional instruction and then being inlined all over the place. llvm-svn: 123911
* remove the AllowAggressive argument to FoldOpIntoPhi. It is forced to false ↵Chris Lattner2011-01-161-2/+2
| | | | | | | | in the first line of the function because it isn't a good idea, even for compares. llvm-svn: 123566
* fix typoChris Lattner2011-01-151-1/+1
| | | | llvm-svn: 123516
* Catch ~x < cst just like ~x < ~y, we currently handle this throughChris Lattner2011-01-151-4/+8
| | | | | | means that are about to disappear. llvm-svn: 123515
* Remove dead variable, const-ref-ize an APInt.Owen Anderson2011-01-111-4/+1
| | | | llvm-svn: 123248
* Fix a random missed optimization by making InstCombine more aggressive when ↵Owen Anderson2011-01-111-2/+40
| | | | | | | | determining which bits are demanded by a comparison against a constant. llvm-svn: 123203
* recognize an unsigned add with overflow idiom into uadd.Chris Lattner2010-12-191-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | This resolves a README entry and technically resolves PR4916, but we still get poor code for the testcase in that PR because GVN isn't CSE'ing uadd with add, filed as PR8817. Previously we got: _test7: ## @test7 addq %rsi, %rdi cmpq %rdi, %rsi movl $42, %eax cmovaq %rsi, %rax ret Now we get: _test7: ## @test7 addq %rsi, %rdi movl $42, %eax cmovbq %rsi, %rax ret llvm-svn: 122182
* use IC.ReplaceInstUsesWith instead of a raw RAUW so that uses ofChris Lattner2010-12-191-3/+5
| | | | | | | | the old thing end up on the instcombine worklist. Not doing this can cause an extra top-level iteration of instcombine, burning compile time. llvm-svn: 122179
* generalize the sadd creation code to not require that theChris Lattner2010-12-191-39/+16
| | | | | | | | | | | | | | sadd formed is half the size of the original type. We can now compile this into a sadd.i8: unsigned char X(char a, char b) { int res = a+b; if ((unsigned )(res+128) > 255U) abort(); return res; } llvm-svn: 122178
* fix another miscompile in the llvm.sadd formation logic: it wasn't Chris Lattner2010-12-191-4/+39
| | | | | | | | | checking to see if the high bits of the original add result were dead. Inserting a smaller add and zexting back to that size is not good enough. This is likely to be the fix for 8816. llvm-svn: 122177
* fix a bug (possibly 8816) in the sadd forming xform: it isn'tChris Lattner2010-12-191-0/+10
| | | | | | | profitable (or safe) to promote code when the add-with-constant has other uses. llvm-svn: 122175
* rework the code added in r122072 to pull it out to its ownChris Lattner2010-12-191-61/+64
| | | | | | | helper function, clean up comments, and reduce indentation. No functionality change. llvm-svn: 122174
* Reapply r121905 (automatic synthesis of @llvm.sadd.with.overflow) with a fix ↵Owen Anderson2010-12-171-0/+73
| | | | | | | | | for a bug that manifested itself on the DragonEgg self-host bot. Unfortunately, the testcase is pretty messy and doesn't reduce well due to interactions with other parts of InstCombine. llvm-svn: 122072
* Speculatively revert commit 121905 since it looks like it might have broken theDuncan Sands2010-12-161-65/+0
| | | | | | | | | | | dragonegg self-host buildbot. Original commit message: Add an InstCombine transform to recognize instances of manual overflow-safe addition (performing the addition in a wider type and explicitly checking for overflow), and fold them down to intrinsics. This currently only supports signed-addition, but could be generalized if someone works out the magic constant formulas for other operations. llvm-svn: 121965
* Add an InstCombine transform to recognize instances of manual overflow-safe ↵Owen Anderson2010-12-151-0/+65
| | | | | | | | | | | | addition (performing the addition in a wider type and explicitly checking for overflow), and fold them down to intrinsics. This currently only supports signed-addition, but could be generalized if someone works out the magic constant formulas for other operations. Fixes <rdar://problem/8558713>. llvm-svn: 121905
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-6/+3
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. llvm-svn: 121120
* PR5207: Rename overloaded APInt methods set(), clear(), flip() toJay Foad2010-12-011-2/+2
| | | | | | setAllBits(), setBit(unsigned), etc. llvm-svn: 120564
* duncan's spider sense was right, I completely reversed the conditionChris Lattner2010-11-231-8/+8
| | | | | | on this instcombine xform. This fixes a miscompilation of 403.gcc. llvm-svn: 119988
* optimize:Chris Lattner2010-11-211-2/+72
| | | | | | | | | void a(int x) { if (((1<<x)&8)==0) b(); } into "x != 3", which occurs over 100 times in 403.gcc but in no other program in llvm-test. llvm-svn: 119922
* PR7750: !CExpr->isNullValue() only properly computes whether CExpr is nonnullEli Friedman2010-07-291-1/+1
| | | | | | if CExpr is a ConstantInt. llvm-svn: 109773
* Convert some tab stops into spaces.Duncan Sands2010-07-121-1/+1
| | | | llvm-svn: 108130
* use ArgOperand APIGabor Greif2010-06-241-3/+3
| | | | llvm-svn: 106752
* Teach instCombine to remove malloc+free if malloc's only uses are comparisonsDuncan Sands2010-05-271-29/+0
| | | | | | to null. Patch by Matti Niemenmaa. llvm-svn: 104871
* Revert 101465, it broke internal OpenGL testing.Eric Christopher2010-04-161-3/+3
| | | | | | | Probably the best way to know that all getOperand() calls have been handled is to replace that API instead of updating. llvm-svn: 101579
* reapply r101434Gabor Greif2010-04-161-3/+3
| | | | | | | | | | | | | with a fix for self-hosting rotate CallInst operands, i.e. move callee to the back of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101465
* back out r101423 and r101397, they break llvm-gcc self-host on darwin10Gabor Greif2010-04-161-3/+3
| | | | llvm-svn: 101434
* reapply r101364, which has been backed out in r101368Gabor Greif2010-04-151-3/+3
| | | | | | | | | | | | | with a fix rotate CallInst operands, i.e. move callee to the back of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101397
* back out r101364, as it trips the linux nightlybot on some clang C++ testsGabor Greif2010-04-151-3/+3
| | | | llvm-svn: 101368
* rotate CallInst operands, i.e. move callee to the backGabor Greif2010-04-151-3/+3
| | | | | | | | | | of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101364
* Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience.Dan Gohman2010-04-081-1/+1
| | | | llvm-svn: 100824
* Fix PR6503. This turned into a much more interesting and nasty bug. Various Chris Lattner2010-03-051-8/+9
| | | | | | | | | | | parts of the cmp|cmp and cmp&cmp folding logic wasn't prepared for vectors (unrelated to the bug but noticed while in the code) and the code was *definitely* not safe to use by the (cast icmp)|(cast icmp) handling logic that I added in r95855. Fix all this up by changing the various routines to more consistently use IRBuilder and not pass in the I which had the wrong type. llvm-svn: 97801
* Fix indentation.Dan Gohman2010-02-241-10/+10
| | | | llvm-svn: 97024
* 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-2/+2
| | | | | | isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! llvm-svn: 96223
* cleanups.Chris Lattner2010-02-011-4/+4
| | | | llvm-svn: 94995
* tidy up some stuff duncan pointed out.Chris Lattner2010-01-081-2/+3
| | | | llvm-svn: 93007
* optimize comparisons against cttz/ctlz/ctpop, patch by Alastair Lynn!Chris Lattner2010-01-051-1/+23
| | | | llvm-svn: 92745
* Truncate GEP indexes larger than the pointer size down to pointer sizeChris Lattner2010-01-041-0/+9
| | | | | | | | | | | when doing this transform if the GEP is not inbounds. No testcase because it is very difficult to trigger this: instcombine already canonicalizes GEP indices to pointer size, so it relies specific permutations of the instcombine worklist. Thanks to Duncan for pointing this possible problem out. llvm-svn: 92495
* split instcombine of compares (visit[FI]Cmp) out toChris Lattner2010-01-041-0/+2443
a new InstCombineCompares.cpp file. llvm-svn: 92467
OpenPOWER on IntegriCloud