summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* 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
* 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
* Enhance LICM to promote alias sets whose pointers themselves are stored,Chris Lattner2010-12-191-1/+4
| | | | | | which doesn't affect the memory address being promoted. llvm-svn: 122172
* fix PR8602, a bug in an assertion: a volatile store *of* a pointerChris Lattner2010-12-191-1/+1
| | | | | | | does not make the alias set for that pointer volatile, just stores *to* the pointer. llvm-svn: 122171
* revert r122164, I'm going to go with a different approach.Chris Lattner2010-12-191-11/+0
| | | | llvm-svn: 122168
* first step to fixing PR8642: don't fold away empty basic blocksChris Lattner2010-12-191-0/+11
| | | | | | | | which have trapping constant exprs in them due to PHI nodes. Eliminating them can cause the constant expr to be evalutated on new paths if the input edges are critical. llvm-svn: 122164
* simplify this a bit.Chris Lattner2010-12-181-2/+1
| | | | llvm-svn: 122156
* Whitespace fixes. No functionality change.Bill Wendling2010-12-171-16/+16
| | | | llvm-svn: 122110
* Add vector versions of some existing scalar transforms to aid codegen in ↵Nate Begeman2010-12-171-0/+17
| | | | | | matching psign & pblend operations to the IR produced by clang/gcc for their C idioms. llvm-svn: 122105
* 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
* SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build.Benjamin Kramer2010-12-171-1/+1
| | | | llvm-svn: 122054
* improve switch formation to handle small range Chris Lattner2010-12-171-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | comparisons formed by comparisons. For example, this: void foo(unsigned x) { if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6) bar(); } compiles into: _foo: ## @foo ## BB#0: ## %entry cmpl $6, %edi ja LBB0_2 ## BB#1: ## %entry movl %edi, %eax movl $91, %ecx btq %rax, %rcx jb LBB0_3 instead of: _foo: ## @foo ## BB#0: ## %entry cmpl $2, %edi jb LBB0_4 ## BB#1: ## %switch.early.test cmpl $6, %edi ja LBB0_3 ## BB#2: ## %switch.early.test movl %edi, %eax movl $88, %ecx btq %rax, %rcx jb LBB0_4 This catches a bunch of cases in GCC, which look like this: %804 = load i32* @which_alternative, align 4, !tbaa !0 %805 = icmp ult i32 %804, 2 %806 = icmp eq i32 %804, 3 %or.cond121 = or i1 %805, %806 %807 = icmp eq i32 %804, 4 %or.cond124 = or i1 %or.cond121, %807 br i1 %or.cond124, label %.thread, label %808 turning this into a range comparison. llvm-svn: 122045
* Revert r64460. strtol and friends cannot be marked readonly, even withDan Gohman2010-12-171-1/+2
| | | | | | | | | a null endptr argument, because they may write to errno. This fixes a seflhost miscompile observed on Linux targets when TBAA was enabled. llvm-svn: 122014
* Fix a bug in the loop in JumpThreading::ProcessThreadableEdges() where it ↵Frits van Bommel2010-12-161-2/+2
| | | | | | | | could falsely produce a MultipleDestSentinel value if the first predecessor ended with an 'indirectbr'. If that happened, it caused an unnecessary FindMostPopularDest() call. This wasn't a correctness problem, but it broke the fast path for single-predecessor blocks. llvm-svn: 121966
* 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
* Make memcpyopt TBAA-aware.Dan Gohman2010-12-161-12/+4
| | | | llvm-svn: 121944
* Preserve TBAA tags when doing load PRE.Dan Gohman2010-12-151-3/+8
| | | | llvm-svn: 121921
* 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
* Move Value::getUnderlyingObject to be a standaloneDan Gohman2010-12-153-8/+9
| | | | | | | function so that it can live in Analysis instead of VMCore. llvm-svn: 121885
* Move Sub simplifications and additional Add simplifications out ofDuncan Sands2010-12-151-28/+4
| | | | | | instcombine and into InstructionSimplify. llvm-svn: 121861
OpenPOWER on IntegriCloud