summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* simplify this, isBytewiseValue handles the extra check. We stillChris Lattner2010-12-281-5/+2
| | | | | | | check for "multiple of a byte" in size to make it clear that the >> 3 below is safe. llvm-svn: 122604
* Silence gcc warning about an unused variable when doing a release build.Duncan Sands2010-12-281-0/+1
| | | | llvm-svn: 122593
* fix some issues Frits noticed, add AliasAnalysis as a dependencyChris Lattner2010-12-271-7/+17
| | | | llvm-svn: 122585
* BuildLibCalls: Nuke EmitMemCpy, EmitMemMove and EmitMemSet. They are dead ↵Benjamin Kramer2010-12-271-49/+5
| | | | | | and superseded by IRBuilder. llvm-svn: 122576
* SimplifyLibCalls: Use IRBuilder to simplify code.Benjamin Kramer2010-12-271-67/+48
| | | | llvm-svn: 122575
* have loop-idiom nuke instructions that feed stores that get removed.Chris Lattner2010-12-271-6/+45
| | | | llvm-svn: 122574
* implement enough of the memset inference algorithm to recognize and insert Chris Lattner2010-12-261-11/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | memsets. This is still missing one important validity check, but this is enough to compile stuff like this: void test0(std::vector<char> &X) { for (std::vector<char>::iterator I = X.begin(), E = X.end(); I != E; ++I) *I = 0; } void test1(std::vector<int> &X) { for (long i = 0, e = X.size(); i != e; ++i) X[i] = 0x01010101; } With: $ clang t.cpp -S -o - -O2 -emit-llvm | opt -loop-idiom | opt -O3 | llc to: __Z5test0RSt6vectorIcSaIcEE: ## @_Z5test0RSt6vectorIcSaIcEE ## BB#0: ## %entry subq $8, %rsp movq (%rdi), %rax movq 8(%rdi), %rsi cmpq %rsi, %rax je LBB0_2 ## BB#1: ## %bb.nph subq %rax, %rsi movq %rax, %rdi callq ___bzero LBB0_2: ## %for.end addq $8, %rsp ret ... __Z5test1RSt6vectorIiSaIiEE: ## @_Z5test1RSt6vectorIiSaIiEE ## BB#0: ## %entry subq $8, %rsp movq (%rdi), %rax movq 8(%rdi), %rdx subq %rax, %rdx cmpq $4, %rdx jb LBB1_2 ## BB#1: ## %for.body.preheader andq $-4, %rdx movl $1, %esi movq %rax, %rdi callq _memset LBB1_2: ## %for.end addq $8, %rsp ret llvm-svn: 122573
* start using irbuilder to make mem intrinsics in a few passes.Chris Lattner2010-12-262-107/+35
| | | | llvm-svn: 122572
* sketch more of this out.Chris Lattner2010-12-261-20/+64
| | | | llvm-svn: 122567
* move isBytewiseValue out to ValueTracking.h/cppChris Lattner2010-12-261-68/+1
| | | | llvm-svn: 122565
* actually add the file...Chris Lattner2010-12-261-0/+103
| | | | llvm-svn: 122563
* Start of a pass for recognizing memset and memcpy idioms.Chris Lattner2010-12-262-0/+2
| | | | | | No functionality yet. llvm-svn: 122562
* Simplify code.Benjamin Kramer2010-12-261-1/+1
| | | | llvm-svn: 122561
* don't lose TD infoChris Lattner2010-12-252-3/+3
| | | | llvm-svn: 122556
* switch the inliner alignment enforcement stuff to use theChris Lattner2010-12-251-27/+8
| | | | | | | getOrEnforceKnownAlignment function, which simplifies the code and makes it stronger. llvm-svn: 122555
* Move getOrEnforceKnownAlignment out of instcombine into Transforms/Utils.Chris Lattner2010-12-254-103/+103
| | | | llvm-svn: 122554
* Fix a thinko pointed out by Frits van Bommel: looking through global ↵Benjamin Kramer2010-12-241-22/+19
| | | | | | variables in isBytewiseValue is not safe. llvm-svn: 122550
* MemCpyOpt: Turn memcpys from a constant into a memset if possible.Benjamin Kramer2010-12-241-3/+45
| | | | | | | | | | | | | This allows us to compile "int cst[] = {-1, -1, -1};" into movl $-1, 16(%rsp) movq $-1, 8(%rsp) instead of movl _cst+8(%rip), %eax movl %eax, 16(%rsp) movq _cst(%rip), %rax movq %rax, 8(%rsp) llvm-svn: 122548
* When determining if we can fold (x >> C1) << C2, the bits that we need to ↵Owen Anderson2010-12-231-1/+2
| | | | | | | | verify are zero are not the low bits of x, but the bits that WILL be the low bits after the operation completes. llvm-svn: 122529
* It is possible for SimplifyCFG to cause PHI nodes to become redundant too ↵Owen Anderson2010-12-231-1/+10
| | | | | | | | | | late in the optimization pipeline to be caught by instcombine, and it's not feasible to catch them in SimplifyCFG because the use-lists are in an inconsistent state at the point where it could know that it need to simplify them. Instead, have CodeGenPrepare look for trivially redundant PHIs as part of its general cleanup effort. llvm-svn: 122516
* Preserve the address space when generating bitcasts for MemTransferInst in ↵Mon P Wang2010-12-231-3/+16
| | | | | | ConvertToScalarInfo llvm-svn: 122462
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-233-6/+3
| | | | | | | new gcc warning that complains on self-assignments and self-initializations. llvm-svn: 122458
* InstCombine: creating selects from -1 and 0 is fine, they combine into a ↵Benjamin Kramer2010-12-221-3/+6
| | | | | | sext from i1. llvm-svn: 122453
* Add a generic expansion transform: A op (B op' C) -> (A op B) op' (A op C)Duncan Sands2010-12-225-71/+140
| | | | | | | | if both A op B and A op C simplify. This fires fairly often but doesn't make that much difference. On gcc-as-one-file it removes two "and"s and turns one branch into a select. llvm-svn: 122399
* Add some statistics, good for understanding how much more powerfulDuncan Sands2010-12-221-2/+12
| | | | | | instcombine is compared to instsimplify. llvm-svn: 122397
* Give GVN back the ability to perform simple conditional propagation on ↵Owen Anderson2010-12-211-52/+82
| | | | | | | | | conditional branch values. I still think that LVI should be handling this, but that capability is some ways off in the future, and this matters for some significant benchmarks. llvm-svn: 122378
* Remove dead code.Owen Anderson2010-12-211-9/+0
| | | | llvm-svn: 122371
* GVN's Expression is not POD-like (it contains a SmallVector). Simplify code ↵Benjamin Kramer2010-12-211-13/+3
| | | | | | while at it. llvm-svn: 122362
* Visit instructions deterministically. Use a FIFO so as to approximatelyDuncan Sands2010-12-211-11/+21
| | | | | | | visit instructions before their uses, since InstructionSimplify does a better job in that case. All this prompted by Frits van Bommel. llvm-svn: 122343
* If an instruction simplifies, try again to simplify any uses of it. This isDuncan Sands2010-12-211-4/+32
| | | | | | | not very important since the pass is only used for testing, but it does make it more realistic. Suggested by Frits van Bommel. llvm-svn: 122336
* Pull a few more simplifications out of instcombine (there are stillDuncan Sands2010-12-211-6/+3
| | | | | | plenty left though!), in particular for multiplication. llvm-svn: 122330
* Oops, forgot to add the pass itself!Duncan Sands2010-12-201-0/+69
| | | | llvm-svn: 122265
* Add a new convenience pass for testing InstructionSimplify. PreviouslyDuncan Sands2010-12-202-0/+2
| | | | | | | | | it could only be tested indirectly, via instcombine, gvn or some other pass that makes use of InstructionSimplify, which means that testcases had to be carefully contrived to dance around any other transformations that that pass did. llvm-svn: 122264
* Add a check missing from my last commit and avoid a potential overflow ↵Benjamin Kramer2010-12-201-3/+3
| | | | | | situation. llvm-svn: 122258
* Reduce indentation.Benjamin Kramer2010-12-201-7/+5
| | | | llvm-svn: 122249
* Teach InstCombine to merge (icmp ult (X + CA), C1) | (icmp eq X, C2) into ↵Benjamin Kramer2010-12-201-1/+10
| | | | | | | | | | | | | | | (icmp ult (X + CA), C1 + 1) if C2 + CA == C1. InstCombine creates these so now we compile x == 23 || x == 24 || x == 25 to %x.off = add i32 %x, -23 %1 = icmp ult i32 %x.off, 3 instead of %x.off = add i32 %x, -23 %1 = icmp ult i32 %x.off, 2 %cmp3 = icmp eq i32 %x, 25 %ret2 = or i1 %1, %cmp3 llvm-svn: 122248
* fix PR8807 by making transformConstExprCastCall aware of byval arguments.Chris Lattner2010-12-201-2/+15
| | | | llvm-svn: 122238
* various cleanups for transformConstExprCastCallChris Lattner2010-12-201-13/+10
| | | | llvm-svn: 122237
* when eliding a byval copy due to inlining a readonly function, we haveChris Lattner2010-12-201-4/+43
| | | | | | to make sure that the reused alloca has sufficient alignment. llvm-svn: 122236
* pull byval processing out to its own helper function.Chris Lattner2010-12-201-56/+72
| | | | llvm-svn: 122235
* fix PR8769, a miscompilation by inliner when inlining a function with a byvalChris Lattner2010-12-201-6/+10
| | | | | | | | argument. The generated alloca has to have at least the alignment of the byval, if not, the client may be making assumptions that the new alloca won't satisfy. llvm-svn: 122234
* Avoid dropping the address space when InstCombine optimizes memsetMon P Wang2010-12-201-1/+3
| | | | llvm-svn: 122215
* fix an oversight caught by Frits!Chris Lattner2010-12-191-3/+4
| | | | llvm-svn: 122204
* tidy upChris Lattner2010-12-191-18/+17
| | | | llvm-svn: 122190
* move a transformation to a more logical place, simplifying it.Chris Lattner2010-12-192-16/+7
| | | | llvm-svn: 122183
* 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
* optimize uadd(x, cst) into a comparison when the normal Chris Lattner2010-12-191-0/+16
| | | | | | | result is dead. This is required for my next patch to not regress the testsuite. llvm-svn: 122181
* 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
OpenPOWER on IntegriCloud