aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* factor memcpy/memmove simplification out to its own SimplifyMemTransfer Chris Lattner2008-01-131-35/+42
| | | | | | | method, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45944 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45943 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify some code by adding a InsertBitCastBefore method,Chris Lattner2008-01-131-30/+25
| | | | | | | make memmove->memcpy conversion a bit simpler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45942 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45937 91177308-0d34-0410-b5e6-96231b3b80d8
* Small simplification.Duncan Sands2008-01-131-4/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45932 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45931 91177308-0d34-0410-b5e6-96231b3b80d8
* we don't have to make an explicit copy of a byval argument when Chris Lattner2008-01-121-4/+6
| | | | | | | | inlining a function if we know that the function does not write to *any* memory. This implements test/Transforms/Inline/byval2.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45912 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow clients to specify the inline threshold when creatingChris Lattner2008-01-122-0/+8
| | | | | | | the inliner pass. Patch by Robert Zeh. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45903 91177308-0d34-0410-b5e6-96231b3b80d8
* When DAE drops the varargs part of a function, ensure anyDuncan Sands2008-01-111-2/+15
| | | | | | | attributes on the vararg call arguments are also dropped. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45892 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach argpromote to ruthlessly hack small byval structs when it canChris Lattner2008-01-111-70/+150
| | | | | | | | | | | | | | | | | | | | | | | | get away with it, which exposes opportunities to eliminate the memory objects entirely. For example, we now compile byval.ll to: define internal void @f1(i32 %b.0, i64 %b.1) { entry: %tmp2 = add i32 %b.0, 1 ; <i32> [#uses=0] ret void } define i32 @main() nounwind { entry: call void @f1( i32 1, i64 2 ) ret i32 0 } This seems like it would trigger a lot for code that passes around small structs (e.g. SDOperand's or _Complex)... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45886 91177308-0d34-0410-b5e6-96231b3b80d8
* Use smallptrset instead of std::set for efficiency.Chris Lattner2008-01-111-2/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45878 91177308-0d34-0410-b5e6-96231b3b80d8
* a byval argument is guaranteed to be valid to load.Chris Lattner2008-01-111-4/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45877 91177308-0d34-0410-b5e6-96231b3b80d8
* Update this code to use eraseFromParent where possible. ComputeChris Lattner2008-01-111-26/+27
| | | | | | | whether an argument is byval and pass into isSafeToPromoteArgument. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45876 91177308-0d34-0410-b5e6-96231b3b80d8
* replace a loop with a constant time check.Chris Lattner2008-01-111-3/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45875 91177308-0d34-0410-b5e6-96231b3b80d8
* another minor datastructure tweak.Chris Lattner2008-01-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45874 91177308-0d34-0410-b5e6-96231b3b80d8
* start using smallvector to avoid vector heap thrashing.Chris Lattner2008-01-111-6/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45873 91177308-0d34-0410-b5e6-96231b3b80d8
* When inlining a functino with a byval argument, make an explicit Chris Lattner2008-01-111-6/+57
| | | | | | | copy of it in case the callee modifies the struct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45853 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement PR1795, an instcombine hack for forming GEPs with integer pointer ↵Chris Lattner2008-01-081-3/+53
| | | | | | arithmetic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45745 91177308-0d34-0410-b5e6-96231b3b80d8
* Small cleanup for handling of type/parameter attributeDuncan Sands2008-01-072-10/+13
| | | | | | | incompatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45704 91177308-0d34-0410-b5e6-96231b3b80d8
* Deleting an empty file. Thanks, /usr/bin/patch!Gordon Henriksen2008-01-071-0/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45675 91177308-0d34-0410-b5e6-96231b3b80d8
* 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) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45670 91177308-0d34-0410-b5e6-96231b3b80d8
* The transform that tries to turn calls to bitcast functions intoDuncan Sands2008-01-062-13/+47
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45658 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45657 91177308-0d34-0410-b5e6-96231b3b80d8
* remove a couple more unsafe xforms in the face of overflow.Chris Lattner2008-01-051-9/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45613 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45612 91177308-0d34-0410-b5e6-96231b3b80d8
* fix typoWojciech Matyjewicz2008-01-041-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45594 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR1896Chris Lattner2008-01-041-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45568 91177308-0d34-0410-b5e6-96231b3b80d8
* don't hoist FP additions into unconditional adds + selects. This Chris Lattner2008-01-031-0/+2
| | | | | | | | could theoretically introduce a trap, but is also a performance issue. This speeds up ptrdist/ks by 8%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45533 91177308-0d34-0410-b5e6-96231b3b80d8
* add missing #includeChris Lattner2008-01-021-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45516 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-2978-156/+156
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
* remove attribution from lib Makefiles.Chris Lattner2007-12-296-12/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45415 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45403 91177308-0d34-0410-b5e6-96231b3b80d8
* dead calls to llvm.stacksave can be deleted, even though theyChris Lattner2007-12-291-1/+10
| | | | | | | have potential side-effects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45392 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. :-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45384 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45383 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixing several transforms which would drop the collector attributeGordon Henriksen2007-12-253-0/+8
| | | | | | when copying functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45356 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45354 91177308-0d34-0410-b5e6-96231b3b80d8
* GC poses hazards to the inliner. Consider:Gordon Henriksen2007-12-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | define void @f() { ... call i32 @g() ... } define void @g() { ... } The hazards are: - @f and @g have GC, but they differ GC. Inlining is invalid. This may never occur. - @f has no GC, but @g does. g's GC must be propagated to @f. The other scenarios are safe: - @f and @g have the same GC. - @f and @g have no GC. - @g has no GC. This patch adds inliner checks for the former two scenarios. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45351 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45344 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45311 91177308-0d34-0410-b5e6-96231b3b80d8
* If succ has succ itself as one of the predecessors then doDevang Patel2007-12-221-2/+2
| | | | | | | | not merge current bb and succ even if bb's terminator is unconditional branch to succ. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45305 91177308-0d34-0410-b5e6-96231b3b80d8
* Make DAE not wipe out attributes on calls, and not dropDuncan Sands2007-12-211-36/+55
| | | | | | | | | | | | | | | | return attributes on the floor. In the case of a call to a varargs function where the varargs arguments are being removed, any call attributes on those arguments need to be dropped. I didn't do this because I plan to make it illegal to have such attributes (see next patch). With this change, compiling the gcc filter2 eh test at -O0 and then running opt -std-compile-opts on it results in a correctly working program (compiling at -O1 or higher results in the test failing due to a problem with how we output eh info into the IR). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45285 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45256 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45251 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45250 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow iv reuse if the user is a PHI node which is in turn used as addresses.Evan Cheng2007-12-191-29/+82
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45230 91177308-0d34-0410-b5e6-96231b3b80d8
* When inlining through an 'nounwind' call, mark inlinedDuncan Sands2007-12-193-21/+34
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45218 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45173 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix commentsChristopher Lamb2007-12-181-4/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45170 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an orthogonal transformation of the selection condition from my most ↵Christopher Lamb2007-12-181-30/+2
| | | | | | recent submission. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45169 91177308-0d34-0410-b5e6-96231b3b80d8