summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* The CorrelatedExpressionElimination pass is known to be buggy. Remove it.Bill Wendling2008-01-271-1486/+0
| | | | | | This fixes PR1769. llvm-svn: 46408
* Fold fptrunc(add (fpextend x), (fpextend y)) -> add(x,y), as GCC does.Chris Lattner2008-01-271-3/+75
| | | | llvm-svn: 46406
* If there are no machine instructions emitted for a function, then insertBill Wendling2008-01-261-14/+1
| | | | | | | a "nop" instruction so that we don't have the function's label associated with something that it's not supposed to be associated with. llvm-svn: 46394
* If we have a function like this:Bill Wendling2008-01-261-1/+14
| | | | | | | | | | | | | | | | | | | | | | void bork() { int *address = 0; *address = 0; } It's compiled into LLVM code that looks like this: define void @bork() noreturn nounwind { entry: unreachable } This is bad on some platforms (like PPC) because it will generate the label for the function but no body. The label could end up being associated with some non-code related stuff, like a section. This places a "trap" instruction if the SimplifyCFG pass removed all code from the function leaving only one "unreachable" instruction. llvm-svn: 46387
* DeadStoreElimination can treat byval parameters as if there were alloca's ↵Owen Anderson2008-01-251-5/+6
| | | | | | for the purpose of removing end-of-function stores. llvm-svn: 46351
* Enable the fix I just checked in, silly me.Nick Lewycky2008-01-221-1/+0
| | | | llvm-svn: 46247
* Multiply can be evaluated in a different type, so long as the target type hasNick Lewycky2008-01-221-0/+10
| | | | | | a smaller bitwidth. llvm-svn: 46244
* Make sure the caller doesn't use freed memory.Duncan Sands2008-01-201-1/+3
| | | | | | Fixes PR1935. llvm-svn: 46203
* Initializing an unsigned with ~0UL causes the compilerDuncan Sands2008-01-201-9/+9
| | | | | | to complain on x86-64 (gcc 4.1). Use ~0U instead. llvm-svn: 46197
* I noticed that the trampoline straightening transformation couldDuncan Sands2008-01-141-21/+28
| | | | | | | | | drop attributes on varargs call arguments. Also, it could generate invalid IR if the transformed call already had the 'nest' attribute somewhere (this can never happen for code coming from llvm-gcc, but it's a theoretical possibility). Fix both problems. llvm-svn: 45973
* Turn a memcpy from a double* into a load/store of double instead ofChris Lattner2008-01-141-9/+46
| | | | | | | | | | a load/store of i64. The later prevents promotion/scalarrepl of the source and dest in many cases. This fixes the 300% performance regression of the byval stuff on stepanov_v1p2. llvm-svn: 45945
* factor memcpy/memmove simplification out to its own SimplifyMemTransfer Chris Lattner2008-01-131-35/+42
| | | | | | method, no functionality change. llvm-svn: 45944
* simplify some code. If we can infer alignment for source and dest that are Chris Lattner2008-01-131-21/+22
| | | | | | | greater than memcpy alignment, and if we lower to load/store, use the best alignment info we have. llvm-svn: 45943
* simplify some code by adding a InsertBitCastBefore method,Chris Lattner2008-01-131-30/+25
| | | | | | make memmove->memcpy conversion a bit simpler. llvm-svn: 45942
* Fix PR1907, a nasty miscompilation because instcombine didn'tChris Lattner2008-01-131-2/+8
| | | | | | | realize that ne & sgt was a signed comparison (it was only looking at whether the left compare was signed). llvm-svn: 45937
* When turning a call to a bitcast function into a direct call,Duncan Sands2008-01-131-12/+17
| | | | | | | if this becomes a varargs call then deal correctly with any parameter attributes on the newly vararg call arguments. llvm-svn: 45931
* Implement PR1795, an instcombine hack for forming GEPs with integer pointer ↵Chris Lattner2008-01-081-3/+53
| | | | | | arithmetic. llvm-svn: 45745
* Small cleanup for handling of type/parameter attributeDuncan Sands2008-01-071-8/+11
| | | | | | incompatibility. llvm-svn: 45704
* Deleting an empty file. Thanks, /usr/bin/patch!Gordon Henriksen2008-01-071-0/+0
| | | | llvm-svn: 45675
* With this patch, the LowerGC transformation becomes theGordon Henriksen2008-01-071-350/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ShadowStackCollector, which additionally has reduced overhead with no sacrifice in portability. Considering a function @fun with 8 loop-local roots, ShadowStackCollector introduces the following overhead (x86): ; shadowstack prologue movl L_llvm_gc_root_chain$non_lazy_ptr, %eax movl (%eax), %ecx movl $___gc_fun, 20(%esp) movl $0, 24(%esp) movl $0, 28(%esp) movl $0, 32(%esp) movl $0, 36(%esp) movl $0, 40(%esp) movl $0, 44(%esp) movl $0, 48(%esp) movl $0, 52(%esp) movl %ecx, 16(%esp) leal 16(%esp), %ecx movl %ecx, (%eax) ; shadowstack loop overhead (none) ; shadowstack epilogue movl 48(%esp), %edx movl %edx, (%ecx) ; shadowstack metadata .align 3 ___gc_fun: # __gc_fun .long 8 .space 4 In comparison to LowerGC: ; lowergc prologue movl L_llvm_gc_root_chain$non_lazy_ptr, %eax movl (%eax), %ecx movl %ecx, 48(%esp) movl $8, 52(%esp) movl $0, 60(%esp) movl $0, 56(%esp) movl $0, 68(%esp) movl $0, 64(%esp) movl $0, 76(%esp) movl $0, 72(%esp) movl $0, 84(%esp) movl $0, 80(%esp) movl $0, 92(%esp) movl $0, 88(%esp) movl $0, 100(%esp) movl $0, 96(%esp) movl $0, 108(%esp) movl $0, 104(%esp) movl $0, 116(%esp) movl $0, 112(%esp) ; lowergc loop overhead leal 44(%esp), %eax movl %eax, 56(%esp) leal 40(%esp), %eax movl %eax, 64(%esp) leal 36(%esp), %eax movl %eax, 72(%esp) leal 32(%esp), %eax movl %eax, 80(%esp) leal 28(%esp), %eax movl %eax, 88(%esp) leal 24(%esp), %eax movl %eax, 96(%esp) leal 20(%esp), %eax movl %eax, 104(%esp) leal 16(%esp), %eax movl %eax, 112(%esp) ; lowergc epilogue movl 48(%esp), %edx movl %edx, (%ecx) ; lowergc metadata (none) llvm-svn: 45670
* The transform that tries to turn calls to bitcast functions intoDuncan Sands2008-01-061-10/+45
| | | | | | | | | direct calls bails out unless caller and callee have essentially equivalent parameter attributes. This is illogical - the callee's attributes should be of no relevance here. Rework the logic, which incidentally fixes a crash when removed arguments have attributes. llvm-svn: 45658
* When transforming a call to a bitcast function intoDuncan Sands2008-01-061-45/+16
| | | | | | | | | | | a direct call with cast parameters and cast return value (if any), instcombine was prepared to cast any non-void return value into any other, whether castable or not. Add a new predicate for testing whether casting is valid, and check it both for the return value and (as a cleanup) for the parameters. llvm-svn: 45657
* remove a couple more unsafe xforms in the face of overflow.Chris Lattner2008-01-051-9/+0
| | | | llvm-svn: 45613
* remove the (x-y) < 0 comparison xform, it miscompiles Chris Lattner2008-01-051-11/+5
| | | | | | | things that are not equality comparisons, for example: (2147479553+4096)-2147479553 < 0 != (2147479553+4096) < 2147479553 llvm-svn: 45612
* fix typoWojciech Matyjewicz2008-01-041-1/+1
| | | | llvm-svn: 45594
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-2929-58/+58
| | | | llvm-svn: 45418
* remove attribution from lib Makefiles.Chris Lattner2007-12-291-2/+2
| | | | llvm-svn: 45415
* Disable null pointer folding transforms for non-generic address spaces. This ↵Christopher Lamb2007-12-292-4/+12
| | | | | | should probably be a target-specific predicate based on address space. That way for targets where this isn't applicable the predicate can be optimized away. llvm-svn: 45403
* Repair a transform that Chris noticed a bug in. Thanks to Nicholas for ↵Owen Anderson2007-12-281-5/+12
| | | | | | pointing out my stupid mistakes when writing this patch. :-) llvm-svn: 45384
* disable this instcombine xform, it miscompiles:Chris Lattner2007-12-281-0/+2
| | | | | | | | | | | | | | | | | | | define i32 @main() { entry: %z = alloca i32 ; <i32*> [#uses=2] store i32 0, i32* %z %tmp = load i32* %z ; <i32> [#uses=1] %sub = sub i32 %tmp, 1 ; <i32> [#uses=1] %cmp = icmp ult i32 %sub, 0 ; <i1> [#uses=1] %retval = select i1 %cmp, i32 1, i32 0 ; <i32> [#uses=1] ret i32 %retval } into ret 1, instead of ret 0. Christopher, please investigate. llvm-svn: 45383
* Don't break critical edges for single-bb loops, this helps with PR1877, thoughChris Lattner2007-12-251-3/+1
| | | | | | | | | | it is only a partial fix. This change is noise for most programs, but speeds up Shootout-C++/matrix by 20%, Ptrdist/ks by 24%, smg2000 by 8%, hexxagon by 9%, bzip2 by 9% (not sure I trust this), ackerman by 13%, etc. OTOH, it slows down Shootout/fib2 by 40% (I'll update PR1877 with this info). llvm-svn: 45354
* add a -backedge-hack llc-beta option to codegenprepare.Chris Lattner2007-12-241-2/+10
| | | | | | | When specified, don't split backedges of single-bb loops. This helps address PR1877 llvm-svn: 45344
* implement InstCombine/shift-trunc-shift.ll. This allowsChris Lattner2007-12-221-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | us to compile: #include <math.h> int t1(double d) { return signbit(d); } into: _t1: movd %xmm0, %rax shrq $63, %rax ret instead of: _t1: movd %xmm0, %rax shrq $32, %rax shrl $31, %eax ret on x86-64. llvm-svn: 45311
* Implement review feedback, including additional transformsChristopher Lamb2007-12-201-17/+15
| | | | | | | | | (icmp slt (sub A B) 1) -> (icmp sle A B) icmp sgt (sub A B) -1) -> (icmp sge A B) and add testcase. llvm-svn: 45256
* Clean up previous patch: PHI uses should not prevent iv reuse if all other ↵Evan Cheng2007-12-201-35/+16
| | | | | | uses are addresses. This trades a constant multiply for one fewer iv. llvm-svn: 45251
* simplify this code with the new m_Zero() pattern. Make sure the select onlyChris Lattner2007-12-201-18/+10
| | | | | | has a single use, and generalize it to not require N to be a constant. llvm-svn: 45250
* Allow iv reuse if the user is a PHI node which is in turn used as addresses.Evan Cheng2007-12-191-29/+82
| | | | llvm-svn: 45230
* When inlining through an 'nounwind' call, mark inlinedDuncan Sands2007-12-191-9/+2
| | | | | | | | | calls 'nounwind'. It is important for correct C++ exception handling that nounwind markings do not get lost, so this transformation is actually needed for correctness. llvm-svn: 45218
* Fold subtracts into integer compares vs. zero. This improves generate code ↵Christopher Lamb2007-12-181-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | for this case on X86 from _foo: movl $99, %ecx movl 4(%esp), %eax subl %eax, %ecx xorl %edx, %edx testl %ecx, %ecx cmovs %edx, %eax ret to _foo: xorl %ecx, %ecx movl 4(%esp), %eax cmpl $99, %eax cmovg %ecx, %eax ret llvm-svn: 45173
* Fix commentsChristopher Lamb2007-12-181-4/+2
| | | | llvm-svn: 45170
* Remove an orthogonal transformation of the selection condition from my most ↵Christopher Lamb2007-12-181-30/+2
| | | | | | recent submission. llvm-svn: 45169
* Rename isNoReturn to doesNotReturn, and isNoUnwind toDuncan Sands2007-12-182-3/+3
| | | | | | doesNotThrow. llvm-svn: 45160
* Fix typos.Christopher Lamb2007-12-181-1/+1
| | | | llvm-svn: 45159
* Fold certain additions through selects (and their compares) so as to ↵Christopher Lamb2007-12-181-0/+61
| | | | | | | | eliminate subtractions. This code is often produced by the SMAX expansion in SCEV. This implements test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll llvm-svn: 45158
* Get rid of annoying spaces.David Greene2007-12-171-1/+1
| | | | llvm-svn: 45100
* Fix GLIBCXX_DEBUG errors. Erase invalidates std::vector iteratorsDavid Greene2007-12-171-4/+3
| | | | | | passed the erased element. llvm-svn: 45099
* Change the PointerType api for creating pointer types. The old functionality ↵Christopher Lamb2007-12-172-19/+27
| | | | | | of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space. llvm-svn: 45082
* Make instcombine promote inline asm calls to 'nounwind'Duncan Sands2007-12-161-0/+13
| | | | | | | | | | | | | calls. Remove special casing of inline asm from the inliner. There is a potential problem: the verifier rejects invokes of inline asm (not sure why). If an asm call is not marked "nounwind" in some .ll, and instcombine is not run, but the inliner is run, then an illegal module will be created. This is bad but I'm not sure what the best approach is. I'm tempted to remove the check in the verifier... llvm-svn: 45073
* Fix typo.Evan Cheng2007-12-131-1/+1
| | | | llvm-svn: 44997
* Be extra careful with extension use optimation. Now turned on by default.Evan Cheng2007-12-131-3/+10
| | | | llvm-svn: 44981
OpenPOWER on IntegriCloud