summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* fix a buggy check that accidentally disabled this xformChris Lattner2006-10-151-1/+1
| | | | llvm-svn: 30967
* Replace custom dispatch code with two uses of InstVisitor. ImprovesNick Lewycky2006-10-121-93/+113
| | | | | | compile-time performance. llvm-svn: 30896
* Implement SROA of unions with mixed pointers/integers in them. This implementsChris Lattner2006-10-081-10/+16
| | | | | | PR892 and Transforms/ScalarRepl/union-pointer.ll:test2 llvm-svn: 30825
* Implement Transforms/ScalarRepl/union-pointer.ll:testChris Lattner2006-10-081-9/+13
| | | | llvm-svn: 30823
* add a new SimplifyDemandedVectorElts method, which works similarly toChris Lattner2006-10-051-8/+254
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SimplifyDemandedBits. The idea is that some operations can be simplified if not all of the computed elements are needed. Some targets (like x86) have a large number of intrinsics that operate on a single element, but pass other elts through unmodified. If those other elements are not needed, the intrinsics can be simplified to scalar operations, and insertelement ops can be removed. This turns (f.e.): ushort %Convert_sse(float %f) { %tmp = insertelement <4 x float> undef, float %f, uint 0 ; <<4 x float>> [#uses=1] %tmp10 = insertelement <4 x float> %tmp, float 0.000000e+00, uint 1 ; <<4 x float>> [#uses=1] %tmp11 = insertelement <4 x float> %tmp10, float 0.000000e+00, uint 2 ; <<4 x float>> [#uses=1] %tmp12 = insertelement <4 x float> %tmp11, float 0.000000e+00, uint 3 ; <<4 x float>> [#uses=1] %tmp28 = tail call <4 x float> %llvm.x86.sse.sub.ss( <4 x float> %tmp12, <4 x float> < float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > ) ; <<4 x float>> [#uses=1] %tmp37 = tail call <4 x float> %llvm.x86.sse.mul.ss( <4 x float> %tmp28, <4 x float> < float 5.000000e-01, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > ) ; <<4 x float>> [#uses=1] %tmp48 = tail call <4 x float> %llvm.x86.sse.min.ss( <4 x float> %tmp37, <4 x float> < float 6.553500e+04, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > ) ; <<4 x float>> [#uses=1] %tmp59 = tail call <4 x float> %llvm.x86.sse.max.ss( <4 x float> %tmp48, <4 x float> zeroinitializer ) ; <<4 x float>> [#uses=1] %tmp = tail call int %llvm.x86.sse.cvttss2si( <4 x float> %tmp59 ) ; <int> [#uses=1] %tmp69 = cast int %tmp to ushort ; <ushort> [#uses=1] ret ushort %tmp69 } into: ushort %Convert_sse(float %f) { entry: %tmp28 = sub float %f, 1.000000e+00 ; <float> [#uses=1] %tmp37 = mul float %tmp28, 5.000000e-01 ; <float> [#uses=1] %tmp375 = insertelement <4 x float> undef, float %tmp37, uint 0 ; <<4 x float>> [#uses=1] %tmp48 = tail call <4 x float> %llvm.x86.sse.min.ss( <4 x float> %tmp375, <4 x float> < float 6.553500e+04, float undef, float undef, float undef > ) ; <<4 x float>> [#uses=1] %tmp59 = tail call <4 x float> %llvm.x86.sse.max.ss( <4 x float> %tmp48, <4 x float> < float 0.000000e+00, float undef, float undef, float undef > ) ; <<4 x float>> [#uses=1] %tmp = tail call int %llvm.x86.sse.cvttss2si( <4 x float> %tmp59 ) ; <int> [#uses=1] %tmp69 = cast int %tmp to ushort ; <ushort> [#uses=1] ret ushort %tmp69 } which improves codegen from: _Convert_sse: movss LCPI1_0, %xmm0 movss 4(%esp), %xmm1 subss %xmm0, %xmm1 movss LCPI1_1, %xmm0 mulss %xmm0, %xmm1 movss LCPI1_2, %xmm0 minss %xmm0, %xmm1 xorps %xmm0, %xmm0 maxss %xmm0, %xmm1 cvttss2si %xmm1, %eax andl $65535, %eax ret to: _Convert_sse: movss 4(%esp), %xmm0 subss LCPI1_0, %xmm0 mulss LCPI1_1, %xmm0 movss LCPI1_2, %xmm1 minss %xmm1, %xmm0 xorps %xmm1, %xmm1 maxss %xmm1, %xmm0 cvttss2si %xmm0, %eax andl $65535, %eax ret This is just a first step, it can be extended in many ways. Testcase here: Transforms/InstCombine/vec_demanded_elts.ll llvm-svn: 30752
* Simplify logic further.Nick Lewycky2006-10-031-17/+8
| | | | | | | Ensure that we copy KnownProperties before calling visitBasicBlock, else we may leak properties into blocks where they don't belong. llvm-svn: 30705
* Simplify, now that predsimplify depends on break-crit-edges.Nick Lewycky2006-10-031-26/+8
| | | | | | Fix SwitchInst where dest-block is the same as one of the cases. llvm-svn: 30700
* Move break-crit-edges before the predicate simplifier. Allows us toNick Lewycky2006-10-031-7/+3
| | | | | | optimize in more cases. llvm-svn: 30699
* Fix a bug from r1.391 of this file, where we checked the size instead ofChris Lattner2006-10-011-2/+2
| | | | | | | the alignment when promoting allocations. This implements InstCombine/cast.ll:test32 llvm-svn: 30682
* Eliminate ConstantBool::True and ConstantBool::False. Instead, provideChris Lattner2006-09-285-115/+108
| | | | | | ConstantBool::getTrue() and ConstantBool::getFalse(). llvm-svn: 30665
* set DEBUG_TYPE rightChris Lattner2006-09-271-0/+1
| | | | llvm-svn: 30623
* Style changes only. Remove dead code, fix a comment.Nick Lewycky2006-09-231-11/+4
| | | | llvm-svn: 30588
* Fix Transforms/IndVarsSimplify/2006-09-20-LFTR-Crash.llChris Lattner2006-09-211-15/+22
| | | | llvm-svn: 30555
* Don't rewrite ConstantExpr::get.Nick Lewycky2006-09-211-44/+20
| | | | llvm-svn: 30552
* Once we're down to "setcc type constant1, constant2", at least come upNick Lewycky2006-09-201-18/+14
| | | | | | with the right answer. llvm-svn: 30550
* Use a total ordering to compare instructions.Nick Lewycky2006-09-201-87/+101
| | | | | | Fixes infinite loop in resolve(). llvm-svn: 30540
* simplifyAndrew Lenharth2006-09-201-12/+8
| | | | llvm-svn: 30535
* We went through all that trouble to compute whether it was safe to transformChris Lattner2006-09-201-6/+46
| | | | | | | this comparison, but never checked it. Whoops, no wonder we miscompiled 177.mesa! llvm-svn: 30511
* Back out Chris' last set of changes. This breaks 177.mesa and povray somehow.Evan Cheng2006-09-201-43/+6
| | | | llvm-svn: 30505
* 80 col.Evan Cheng2006-09-201-1/+2
| | | | llvm-svn: 30504
* If we have an add, do it in the pointer realm, not the int realm. This is ↵Andrew Lenharth2006-09-191-0/+22
| | | | | | critical in the linux kernel for pointer analysis correctness llvm-svn: 30496
* implement select.ll:test19-22Chris Lattner2006-09-191-6/+43
| | | | llvm-svn: 30482
* Walk down the dominator tree instead of the control flow graph. That meansNick Lewycky2006-09-181-150/+90
| | | | | | | that we can't modify the CFG any more, at least not until it's possible to update the dominator tree (PR217). llvm-svn: 30469
* Fix an infinite loop building the CFEChris Lattner2006-09-181-1/+2
| | | | llvm-svn: 30465
* Implement InstCombine/cast.ll:test31. This speeds up 462.libquantum by 26%.Chris Lattner2006-09-181-4/+39
| | | | llvm-svn: 30456
* Implement Transforms/InstCombine/shift-sra.ll:test0Chris Lattner2006-09-181-0/+20
| | | | llvm-svn: 30450
* Rewrite shift/and/compare sequences to promote better licm of the RHS.Chris Lattner2006-09-181-28/+48
| | | | | | Use isLogicalShift/isArithmeticShift to simplify code. llvm-svn: 30448
* Fix Transforms/InstCombine/2006-09-15-CastToBool.ll and PR913Chris Lattner2006-09-161-0/+5
| | | | llvm-svn: 30405
* Add some more consistency checks.Nick Lewycky2006-09-131-1/+20
| | | | llvm-svn: 30305
* Fix unionSets so that it can merge correctly.Nick Lewycky2006-09-131-22/+34
| | | | llvm-svn: 30304
* Erase dead instructions.Nick Lewycky2006-09-131-2/+3
| | | | llvm-svn: 30298
* An sinkable instruction may exist with uses, if those uses are in dead blocks.Chris Lattner2006-09-121-0/+4
| | | | | | Handle this. This fixes PR908 and Transforms/LICM/2006-09-12-DeadUserOfSunkInstr.ll llvm-svn: 30275
* Fix PR905 and InstCombine/2006-09-11-EmptyStructCrash.llChris Lattner2006-09-111-1/+2
| | | | llvm-svn: 30266
* Skip the linear search if the answer is already known.Nick Lewycky2006-09-111-20/+22
| | | | llvm-svn: 30251
* Allow tail duplication in more cases, relaxing the previous restriction aChris Lattner2006-09-101-1/+12
| | | | | | bit. This fixes Regression/Transforms/TailDup/MergeTest.ll llvm-svn: 30237
* Replace EquivalenceClasses with a custom-built data structure. Many commonNick Lewycky2006-09-101-133/+259
| | | | | | | | | operations (like findProperties) should be faster, at the expense of unionSets being slower in cases that are rare in practise. Don't erase a dead Instruction. This fixes a memory corruption issue. llvm-svn: 30235
* Implement Transforms/InstCombine/hoist_instr.llChris Lattner2006-09-091-14/+54
| | | | llvm-svn: 30234
* Turn div X, (Cond ? Y : 0) -> div X, YChris Lattner2006-09-091-19/+68
| | | | | | This implements select.ll::test18. llvm-svn: 30230
* Throttle back tail duplication to avoid creating really ugly sequences of code.Chris Lattner2006-09-071-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For Transforms/TailDup/if-tail-dup.ll, f.e., it produces: _foo: movl 8(%esp), %eax movl 4(%esp), %ecx testl $1, %ecx je LBB1_2 #cond_next LBB1_1: #cond_true movl $1, (%eax) LBB1_2: #cond_next testl $2, %ecx je LBB1_4 #cond_next10 LBB1_3: #cond_true6 movl $1, 4(%eax) LBB1_4: #cond_next10 testl $4, %ecx je LBB1_6 #cond_next18 LBB1_5: #cond_true14 movl $1, 8(%eax) LBB1_6: #cond_next18 testl $8, %ecx je LBB1_8 #return LBB1_7: #cond_true22 movl $1, 12(%eax) ret LBB1_8: #return ret instead of: _foo: movl 4(%esp), %eax testl $2, %eax sete %cl movl 8(%esp), %edx testl $1, %eax je LBB1_2 #cond_next LBB1_1: #cond_true movl $1, (%edx) testb %cl, %cl jne LBB1_4 #cond_next10 jmp LBB1_3 #cond_true6 LBB1_2: #cond_next testb %cl, %cl jne LBB1_4 #cond_next10 LBB1_3: #cond_true6 movl $1, 4(%edx) testl $4, %eax je LBB1_6 #cond_next18 jmp LBB1_5 #cond_true14 LBB1_4: #cond_next10 testl $4, %eax je LBB1_6 #cond_next18 LBB1_5: #cond_true14 movl $1, 8(%edx) testl $8, %eax je LBB1_8 #return jmp LBB1_7 #cond_true22 LBB1_6: #cond_next18 testl $8, %eax je LBB1_8 #return LBB1_7: #cond_true22 movl $1, 12(%edx) ret LBB1_8: #return ret llvm-svn: 30158
* Improve handling of SelectInst.Nick Lewycky2006-09-021-31/+44
| | | | | | | | Reorder operations to remove duplicated work. Fix to leave floating-point types out of the optimization. Add tests to predsimplify.ll for SwitchInst and SelectInst handling. llvm-svn: 30055
* Don't confuse canonicalize and lookup. Fixes predsimplify.reg4.ll. AlsoNick Lewycky2006-09-011-21/+20
| | | | | | corrects missing optimization opportunity removing cases from a switch. llvm-svn: 30009
* Properties where both Values weren't in the union (as being equal toNick Lewycky2006-08-311-24/+18
| | | | | | | | another Value) weren't being found by findProperties. This fixes predsimplify.ll test6, a missed optimization opportunity. llvm-svn: 29991
* Move to using the EquivalenceClass ADT. Removes SynSets.Nick Lewycky2006-08-301-165/+92
| | | | | | | | | If a branch's condition has become a ConstantBool, simplify it immediately. Removing the edge saves work and exposes up more optimization opportunities in the pass. Add support for SelectInst. llvm-svn: 29970
* Do not rely on std::sort and std::erase to get list of uniqueDevang Patel2006-08-291-10/+4
| | | | | | | | exit blocks. The output is dependent on addresses of basic block. Add and use Loop::getUniqueExitBlocks. llvm-svn: 29966
* Clean up a bit.Owen Anderson2006-08-291-51/+32
| | | | llvm-svn: 29950
* Add PredicateSimplifier pass. Collapses equal variables into one formNick Lewycky2006-08-281-0/+744
| | | | | | | and simplifies expressions. This implements the optimization described in PR807. llvm-svn: 29947
* Make LoopUnroll fold excessive BasicBlocks. This results in a significant ↵Owen Anderson2006-08-281-9/+89
| | | | | | | | speedup of gccas on 252.eon llvm-svn: 29936
* eliminate RegisterOpt. It does the same thing as RegisterPass.Chris Lattner2006-08-2723-27/+27
| | | | llvm-svn: 29925
* s|llvm/Support/Visibility.h|llvm/Support/Compiler.h|Chris Lattner2006-08-274-4/+4
| | | | llvm-svn: 29911
* Fix a crash related to updating Phi nodes in the original header block. ↵Owen Anderson2006-08-251-1/+2
| | | | | | | | This was causing a crash in 175.vpr llvm-svn: 29887
OpenPOWER on IntegriCloud