aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* Turn store -> null/undef into the LLVM unreachable instruction! This simpleChris Lattner2004-10-181-0/+27
| | | | | | | | | change hacks off 10K of bytecode from perlbmk (.5%) even though the front-end is not generating them yet and we are not optimizing the resultant code. This isn't too bad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17111 91177308-0d34-0410-b5e6-96231b3b80d8
* Turn things with obviously undefined semantics into 'store -> null'Chris Lattner2004-10-181-26/+34
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17110 91177308-0d34-0410-b5e6-96231b3b80d8
* My friend the invoke instruction does not dominate all basic blocks if itChris Lattner2004-10-181-1/+2
| | | | | | | occurs in the entry node of a function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17109 91177308-0d34-0410-b5e6-96231b3b80d8
* Getting ADCE to interact well with unreachable instructions seems like a ↵Chris Lattner2004-10-171-2/+3
| | | | | | | | | | | | nontrivial exercise that I'm not interested in tackling right now. Just punt and treat them like unwind's. This 'fixes' test/Regression/Transforms/ADCE/unreachable-function.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17106 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove printout, realize that instructions in the entry block dominate allChris Lattner2004-10-171-6/+6
| | | | | | | other blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17099 91177308-0d34-0410-b5e6-96231b3b80d8
* hasConstantValue will soon return instructions that don't dominate the PHI node,Chris Lattner2004-10-171-4/+18
| | | | | | | so prepare for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17095 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a type violationChris Lattner2004-10-161-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17069 91177308-0d34-0410-b5e6-96231b3b80d8
* Kill the bogon that slipped into my buffer before I committed.Chris Lattner2004-10-161-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17067 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement InstCombine/getelementptr.ll:test9, which is the source of manyChris Lattner2004-10-161-0/+18
| | | | | | | ugly and giant constnat exprs in some programs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17066 91177308-0d34-0410-b5e6-96231b3b80d8
* Optimize instructions involving undef values. For example X+undef == undef.Chris Lattner2004-10-161-27/+125
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17047 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle undef values as undefined on the constant latticeChris Lattner2004-10-161-3/+6
| | | | | | | ignore unreachable instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17044 91177308-0d34-0410-b5e6-96231b3b80d8
* Add noteChris Lattner2004-10-161-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17043 91177308-0d34-0410-b5e6-96231b3b80d8
* Update to reflect changes in Makefile rules.Reid Spencer2004-10-131-4/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16950 91177308-0d34-0410-b5e6-96231b3b80d8
* Transform memmove -> memcpy when the source is obviously constant memory.Chris Lattner2004-10-121-16/+33
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16932 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a REALLY obscure bug in my previous checkin, which was splicing the ENDChris Lattner2004-10-121-1/+1
| | | | | | | marker from one ilist into the middle of another basic block! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16925 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle a common case more carefully. In particular, instead of transformingChris Lattner2004-10-111-4/+33
| | | | | | | | | | | | | | | | | | pointer recurrences into expressions from this: %P_addr.0.i.0 = phi sbyte* [ getelementptr ([8 x sbyte]* %.str_1, int 0, int 0), %entry ], [ %inc.0.i, %no_exit.i ] %inc.0.i = getelementptr sbyte* %P_addr.0.i.0, int 1 ; <sbyte*> [#uses=2] into this: %inc.0.i = getelementptr sbyte* getelementptr ([8 x sbyte]* %.str_1, int 0, int 0), int %inc.0.i.rec Actually create something nice, like this: %inc.0.i = getelementptr [8 x sbyte]* %.str_1, int 0, int %inc.0.i.rec git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16924 91177308-0d34-0410-b5e6-96231b3b80d8
* Reenable the transform, turning X/-10 < 1 into X > -10Chris Lattner2004-10-111-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16918 91177308-0d34-0410-b5e6-96231b3b80d8
* Initial version of automake Makefile.am file.Reid Spencer2004-10-101-0/+50
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16893 91177308-0d34-0410-b5e6-96231b3b80d8
* Use DEBUG instead of DebugFlag directly, as DebugFlag does not respectChris Lattner2004-10-091-5/+3
| | | | | | | -debug-only! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16868 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement sub.ll:test17, -X/C -> X/-CChris Lattner2004-10-091-0/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16863 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily disable a buggy transformation until it can be fixed. This fixesChris Lattner2004-10-081-0/+5
| | | | | | | 254.gap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16853 91177308-0d34-0410-b5e6-96231b3b80d8
* Instcombine (X & FF00) + xx00 -> (X+xx00) & FF00, implementing and.ll:test27Chris Lattner2004-10-081-0/+25
| | | | | | | This comes up when doing adds to bitfield elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16836 91177308-0d34-0410-b5e6-96231b3b80d8
* Little patch to turn (shl (add X, 123), 4) -> (add (shl X, 4), 123 << 4)Chris Lattner2004-10-081-0/+3
| | | | | | | | This triggers in cases of bitfield additions, opening opportunities for future improvements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16834 91177308-0d34-0410-b5e6-96231b3b80d8
* Instcombine: -(X sdiv C) -> (X sdiv -C), tested by sub.ll:test16Chris Lattner2004-10-061-0/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16769 91177308-0d34-0410-b5e6-96231b3b80d8
* Reduce code growth implied by the tail duplication pass by not duplicatingChris Lattner2004-10-061-0/+75
| | | | | | | | an instruction if it can be hoisted to a common dominator of the block. This implements: test/Regression/Transforms/TailDup/MergeTest.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16758 91177308-0d34-0410-b5e6-96231b3b80d8
* Hrm, debugging printouts do not need to be in hereChris Lattner2004-09-291-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16598 91177308-0d34-0410-b5e6-96231b3b80d8
* * Pull range optimization code out into new InsertRangeTest function.Chris Lattner2004-09-291-80/+219
| | | | | | | | | | | * SubOne/AddOne functions always return ConstantInt, declare them as such * Pull code for handling setcc X, cst, where cst is at the end of the range, or cc is LE or GE up earlier in visitSetCondInst. This reduces #iterations in some cases. * Fold: (div X, C1) op C2 -> range check, implementing div.ll:test6 - test9. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16588 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold binary expressions and casts into PHI nodes that have all constant inputs.Chris Lattner2004-09-291-1/+86
| | | | | | | | | | | | | | | | | | | | This takes something like this: %A = phi int [ 3, %cond_false.0 ], [ 2, %endif.0.i ], [ 2, %endif.1.i ] %B = div int %tmp.243, 4 and turns it into: %A = phi int [ 3/4, %cond_false.0 ], [ 2/4, %endif.0.i ], [ 2/4, %endif.1.i ] which is later simplified (in this case) into %A = 0. This triggers thousands of times in spec, for example, 269 times in 176.gcc. This is tested by InstCombine/add.ll:test23 and set.ll:test18. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16582 91177308-0d34-0410-b5e6-96231b3b80d8
* Hrm, really, all tests passed without this, but it is scary to think how...Chris Lattner2004-09-291-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16568 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove debugging printoutChris Lattner2004-09-291-1/+38
| | | | | | | | | | | | Instcombine (setcc (truncate X), C1). This occurs THOUSANDS of times in many benchmarks. Particularlly common seem to be things like (seteq (cast bool X to int), int 0) This turns it into (seteq bool %X, false), which then becomes (not %X). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16567 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold (X setcc C1) | (X setcc C2)Chris Lattner2004-09-281-1/+102
| | | | | | | This implements or.ll:test1[89] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16561 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold (and (setcc X, C1), (setcc X, C2))Chris Lattner2004-09-281-20/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is important for several reasons: 1. Benchmarks have lots of code that looks like this (perlbmk in particular): %tmp.2.i = setne int %tmp.0.i, 128 ; <bool> [#uses=1] %tmp.6343 = seteq int %tmp.0.i, 1 ; <bool> [#uses=1] %tmp.63 = and bool %tmp.2.i, %tmp.6343 ; <bool> [#uses=1] we now fold away the setne, a clear improvement. 2. In the more important cases, such as (X >= 10) & (X < 20), we now produce smaller code: (X-10) < 10. 3. Perhaps the nicest effect of this patch is that it really helps out the code generators. In particular, for a 'range test' like the above, instead of generating this on X86 (the difference on PPC is even more pronounced): cmp %EAX, 50 setge %CL cmp %EAX, 100 setl %AL and %CL, %AL cmp %CL, 0 we now generate this: add %EAX, -50 cmp %EAX, 50 Furthermore, this causes setcc's to be folded into branches more often. These combinations trigger dozens of times in the spec benchmarks, particularly in 176.gcc, 186.crafty, 253.perlbmk, 254.gap, & 099.go. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16559 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement X / C1 / C2 foldingChris Lattner2004-09-281-8/+54
| | | | | | | | | | | | Implement (setcc (shl X, C1), C2) folding. The second one occurs several dozen times in spec. The first was added just in case. :) These are tested by shift.ll:test2[12], and div.ll:test5 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16549 91177308-0d34-0410-b5e6-96231b3b80d8
* shl is always zero extending, so always use a zero extending shift right.Chris Lattner2004-09-281-5/+12
| | | | | | | | This latent bug was exposed by recent changes, and is tested as: llvm/test/Regression/Transforms/InstCombine/2004-09-28-BadShiftAndSetCC.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16546 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix two bugs: one where a condition was mistakenly swapped, and anotherChris Lattner2004-09-271-14/+11
| | | | | | | | where we folded (X & 254) -> X < 1 instead of X < 2. These problems were latent problems exposed by the latest patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16528 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold: (setcc (shr X, ShAmt), CI), where 'cc' is eq or ne. This xformChris Lattner2004-09-271-0/+45
| | | | | | | | | | | triggers often, for example: 6x in povray, 1x in gzip, 279x in gcc, 1x in crafty, 8x in eon, 11x in perlbmk, 362x in gap, 4x in vortex, 14 in m88ksim, 211x in 126.gcc, 1x in compress, 11x in ijpeg, and 4x in 147.vortex. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16521 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement shift-and combinations, implementing InstCombine/and.ll:test19-21Chris Lattner2004-09-241-7/+44
| | | | | | | These combinations trigger 4 times in povray, 7x in gcc, 4x in gap, and 2x in bzip2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16508 91177308-0d34-0410-b5e6-96231b3b80d8
* Move LHSI->hasOneUse() into the arms of the conditional, reindenting code.Chris Lattner2004-09-231-71/+72
| | | | | | | No functionality changes here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16505 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement Transforms/InstCombine/and.ll:test18, a case that occurs 20 timesChris Lattner2004-09-231-0/+45
| | | | | | | in perlbmk git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16504 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement select.ll:test16: fold load (select C, X, null) -> load XChris Lattner2004-09-231-0/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16499 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not fold (X + C1 != C2) if there are other users of the add. DoingChris Lattner2004-09-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this transformation used to take a loop like this: int Array[1000]; void test(int X) { int i; for (i = 0; i < 1000; ++i) Array[i] += X; } Compiled to LLVM is: no_exit: ; preds = %entry, %no_exit %indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=2] %tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar ; <int*> [#uses=2] %tmp.7 = load int* %tmp.4 ; <int> [#uses=1] %tmp.9 = add int %tmp.7, %X ; <int> [#uses=1] store int %tmp.9, int* %tmp.4 *** %indvar.next = add uint %indvar, 1 ; <uint> [#uses=2] *** %exitcond = seteq uint %indvar.next, 1000 ; <bool> [#uses=1] br bool %exitcond, label %return, label %no_exit and turn it into a loop like this: no_exit: ; preds = %entry, %no_exit %indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=3] %tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar ; <int*> [#uses=2] %tmp.7 = load int* %tmp.4 ; <int> [#uses=1] %tmp.9 = add int %tmp.7, %X ; <int> [#uses=1] store int %tmp.9, int* %tmp.4 *** %indvar.next = add uint %indvar, 1 ; <uint> [#uses=1] *** %exitcond = seteq uint %indvar, 999 ; <bool> [#uses=1] br bool %exitcond, label %return, label %no_exit Note that indvar.next and indvar can no longer be coallesced. In machine code terms, this patch changes this code: .LBBtest_1: # no_exit mov %EDX, OFFSET Array mov %ESI, %EAX add %ESI, DWORD PTR [%EDX + 4*%ECX] mov %EDX, OFFSET Array mov DWORD PTR [%EDX + 4*%ECX], %ESI mov %EDX, %ECX inc %EDX cmp %ECX, 999 mov %ECX, %EDX jne .LBBtest_1 # no_exit into this: .LBBtest_1: # no_exit mov %EDX, OFFSET Array mov %ESI, %EAX add %ESI, DWORD PTR [%EDX + 4*%ECX] mov %EDX, OFFSET Array mov DWORD PTR [%EDX + 4*%ECX], %ESI inc %ECX cmp %ECX, 1000 jne .LBBtest_1 # no_exit We need better instruction selection to get this: .LBBtest_1: # no_exit add DWORD PTR [Array + 4*%ECX], EAX inc %ECX cmp %ECX, 1000 jne .LBBtest_1 # no_exit ... but at least there is less register juggling git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16473 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix potential miscompilations: InstCombine/2004-09-20-BadLoadCombine*.llxChris Lattner2004-09-201-7/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16447 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix loop condition so that we don't decrement off the beginning of theAlkis Evlogimenos2004-09-201-5/+5
| | | | | | | list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16440 91177308-0d34-0410-b5e6-96231b3b80d8
* Prototype these functions more accuratelyChris Lattner2004-09-2010-11/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16432 91177308-0d34-0410-b5e6-96231b3b80d8
* Make isSafeToLoadUnconditionally a bit smarter, implementing PR362 andChris Lattner2004-09-191-6/+28
| | | | | | | Regression/Transforms/InstCombine/CPP_min_max.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16409 91177308-0d34-0410-b5e6-96231b3b80d8
* Make instruction combining a bit more aggressive in the face of volatileChris Lattner2004-09-191-3/+60
| | | | | | | loads, and implement two new transforms: InstCombine/load.ll:test[56]. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16404 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert code to compile with vc7.1.Reid Spencer2004-09-156-13/+18
| | | | | | | Patch contributed by Paolo Invernizzi. Thanks Paolo! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16368 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in the previous checkin that broke 255.vortexChris Lattner2004-09-151-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16355 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure to update alias analysis information as we transform the function.Chris Lattner2004-09-151-21/+57
| | | | | | | This fixes PR420 and Regression/Transforms/LICM/2004-09-14-AliasAnalysisInvalidate.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16348 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a long-dead pass. Actually, this pass was never used at all.Chris Lattner2004-09-141-182/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16337 91177308-0d34-0410-b5e6-96231b3b80d8