aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* Teach the alignment handling code to look through constant expr casts and GEPsChris Lattner2006-03-071-4/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26580 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instcombine to increase the alignment of memset/memcpy/memmove whenChris Lattner2006-03-061-3/+74
| | | | | | | | | | | | | the pointer is known to come from either a global variable, alloca or malloc. This allows us to compile this: P = malloc(28); memset(P, 0, 28); into explicit stores on PPC instead of a memset call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26577 91177308-0d34-0410-b5e6-96231b3b80d8
* Make vector narrowing more effective, implementingChris Lattner2006-03-051-22/+62
| | | | | | | | Transforms/InstCombine/vec_narrow.ll. This add support for narrowing extract_element(insertelement) also. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26538 91177308-0d34-0410-b5e6-96231b3b80d8
* Add factoring of multiplications, e.g. turning A*A+A*B into A*(A+B).Chris Lattner2006-03-041-49/+186
| | | | | | | Testcase here: Transforms/Reassociate/mulfactor.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26524 91177308-0d34-0410-b5e6-96231b3b80d8
* Canonicalize (X+C1)*C2 -> X*C2+C1*C2Chris Lattner2006-03-041-0/+13
| | | | | | | This implements Transforms/InstCombine/add.ll:test31 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26519 91177308-0d34-0410-b5e6-96231b3b80d8
* Change this to work with renamed intrinsics.Chris Lattner2006-03-031-1/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26484 91177308-0d34-0410-b5e6-96231b3b80d8
* Make this work with renamed intrinsics.Chris Lattner2006-03-031-26/+25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26482 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize the REM folding code to handle another case Nick LewyckyChris Lattner2006-03-021-13/+43
| | | | | | | pointed out: realize the AND can provide factors and look through Casts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26469 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a regression in a patch from a couple of days ago. This fixesChris Lattner2006-02-281-1/+3
| | | | | | | Transforms/InstCombine/2006-02-28-Crash.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26427 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement rem.ll:test[7-9] and PR712Chris Lattner2006-02-281-6/+22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26415 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify some code now that the RHS of a rem can't be 0Chris Lattner2006-02-281-8/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26413 91177308-0d34-0410-b5e6-96231b3b80d8
* Rearrange some code, fold "rem X, 0", implementing rem.ll:test6Chris Lattner2006-02-281-38/+39
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26411 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge two almost-identical pieces of code.Chris Lattner2006-02-271-46/+42
| | | | | | | | | | | | | | | | | Make this code more powerful by using ComputeMaskedBits instead of looking for an AND operand. This lets us fold this: int %test23(int %a) { %tmp.1 = and int %a, 1 %tmp.2 = seteq int %tmp.1, 0 %tmp.3 = cast bool %tmp.2 to int ;; xor tmp1, 1 ret int %tmp.3 } into: xor (and a, 1), 1 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26396 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold (A^B) == A -> B == 0Chris Lattner2006-02-271-0/+26
| | | | | | | and (A-B) == A -> B == 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26394 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold (X|C1)^C2 -> X^(C1|C2) when possible. This implementsChris Lattner2006-02-261-0/+14
| | | | | | | InstCombine/or.ll:test23. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26385 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a problem that Nate noticed that boils down to an over conservative checkChris Lattner2006-02-241-22/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the code that does "select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y)))". We now compile this loop: LBB1_1: ; no_exit add r6, r2, r3 subf r3, r2, r3 cmpwi cr0, r2, 0 addi r7, r5, 4 lwz r2, 0(r5) addi r4, r4, 1 blt cr0, LBB1_4 ; no_exit LBB1_3: ; no_exit mr r3, r6 LBB1_4: ; no_exit cmpwi cr0, r4, 16 mr r5, r7 bne cr0, LBB1_1 ; no_exit into this instead: LBB1_1: ; no_exit srawi r6, r2, 31 add r2, r2, r6 xor r6, r2, r6 addi r7, r5, 4 lwz r2, 0(r5) addi r4, r4, 1 add r3, r3, r6 cmpwi cr0, r4, 16 mr r5, r7 bne cr0, LBB1_1 ; no_exit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26356 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Regression/Transforms/LoopUnswitch/2006-02-22-UnswitchCrash.ll, whichChris Lattner2006-02-221-1/+3
| | | | | | | | | | caused SPASS to fail building last night. We can't trivially unswitch a loop if the exit block has phi nodes in it, because we don't know which predecessor to use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26320 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some comments, simplify some code, and fix a bug that caused rewritingChris Lattner2006-02-221-34/+26
| | | | | | | to rewrite with the wrong value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26311 91177308-0d34-0410-b5e6-96231b3b80d8
* improved support for branch folding, still not enabled.Chris Lattner2006-02-181-143/+269
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26289 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix bugs identified by VC++.Jeff Cohen2006-02-181-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26287 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement deletion of dead blocks, currently disabled.Chris Lattner2006-02-181-28/+75
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26285 91177308-0d34-0410-b5e6-96231b3b80d8
* a previous patch completely disabled trivial unswitching, this fixees it.Chris Lattner2006-02-181-1/+0
| | | | | | | Thanks to nate for pointing this out :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26280 91177308-0d34-0410-b5e6-96231b3b80d8
* initial trivial support for folding branches that have now-constant ↵Chris Lattner2006-02-181-3/+34
| | | | | | destinations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26279 91177308-0d34-0410-b5e6-96231b3b80d8
* When unswitching a loop, make sure to update loop info with exit blocks inChris Lattner2006-02-181-2/+4
| | | | | | | the right loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26277 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.llChris Lattner2006-02-181-2/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26275 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix loops where the header has an exit, fixing a loop-unswitch crash on craftyChris Lattner2006-02-171-13/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26258 91177308-0d34-0410-b5e6-96231b3b80d8
* start of some new simplification code, not thoroughly tested, use at your ownChris Lattner2006-02-171-14/+161
| | | | | | | risk :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26248 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework the SelectionDAG-based implementations of SimplifyDemandedBitsNate Begeman2006-02-161-3/+3
| | | | | | | | and ComputeMaskedBits to match the new improved versions in instcombine. Tested against all of multisource/benchmarks on ppc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26238 91177308-0d34-0410-b5e6-96231b3b80d8
* Change SplitBlock to increment a BasicBlock::iterator, not an Instruction*. ↵Chris Lattner2006-02-161-23/+27
| | | | | | | | | | | | Apparently they do different things :) This fixes a testcase that nate reduced from spass. Also included are a couple minor code changes that don't affect the generated code at all. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26235 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix VC++ warning.Jeff Cohen2006-02-161-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26228 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bug where we unswitched the wrong wayChris Lattner2006-02-161-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26225 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement trivial unswitching for switch stmts. This allows us to trivialChris Lattner2006-02-151-27/+51
| | | | | | | | | | | | | | | | | | | unswitch this loop on 2 before sweating to unswitch on 1/3. void test4(int N, int i, int C, int*P, int*Q) { int j; for (j = 0; j < N; ++j) { switch (C) { // general unswitching. default: P[i+j] = 0; break; case 1: Q[i+j] = 0; break; case 3: P[i+j] = Q[i+j]; break; case 2: break; // TRIVIAL UNSWITCH on C==2 } } } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26223 91177308-0d34-0410-b5e6-96231b3b80d8
* make "trivial" unswitching significantly more general. It can now handleChris Lattner2006-02-151-47/+79
| | | | | | | | | | | | | | this for example: for (j = 0; j < N; ++j) { // trivial unswitch if (C) P[i+j] = 0; } turning it into the obvious code without bothering to duplicate an empty loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26220 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bunch of alpha regressions. see bug 709Andrew Lenharth2006-02-151-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26218 91177308-0d34-0410-b5e6-96231b3b80d8
* Checking the wrong value. This caused us to emit silly code likeChris Lattner2006-02-151-1/+1
| | | | | | | | Y = seteq bool X, true instead of just using X :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26215 91177308-0d34-0410-b5e6-96231b3b80d8
* more refactoring, no functionality change.Chris Lattner2006-02-151-12/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26194 91177308-0d34-0410-b5e6-96231b3b80d8
* pull some code out into a functionChris Lattner2006-02-151-18/+28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26191 91177308-0d34-0410-b5e6-96231b3b80d8
* Canonicalize inner loops before outer loops. Inner loop canonicalizationChris Lattner2006-02-141-4/+5
| | | | | | | | | can provide work for the outer loop to canonicalize. This fixes a case that breaks unswitching. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26189 91177308-0d34-0410-b5e6-96231b3b80d8
* When splitting exit edges to canonicalize loops, make sure to put the newChris Lattner2006-02-141-18/+20
| | | | | | | | | block in the appropriate loop nest. Third time is the charm, right? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26187 91177308-0d34-0410-b5e6-96231b3b80d8
* Use statistics to keep track of what flavors of loops we are unswitchingChris Lattner2006-02-141-7/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26157 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement Instcombine/and.ll:test34Chris Lattner2006-02-131-0/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26155 91177308-0d34-0410-b5e6-96231b3b80d8
* If any of the sign extended bits are demanded, the input sign bit is demandedChris Lattner2006-02-131-3/+9
| | | | | | | | | for a sign extension. This fixes InstCombine/2006-02-13-DemandedMiscompile.ll and Ptrdist/bc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26152 91177308-0d34-0410-b5e6-96231b3b80d8
* Be careful not to request or look at bits shifted in from outside the sizeChris Lattner2006-02-131-3/+9
| | | | | | | of the input. This fixes the mediabench/gsm/toast failure last night. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26138 91177308-0d34-0410-b5e6-96231b3b80d8
* remove some more dead special case codeChris Lattner2006-02-121-35/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26135 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate special case hacks that are superceded by general purpose hacksChris Lattner2006-02-121-139/+51
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26134 91177308-0d34-0410-b5e6-96231b3b80d8
* Three changes:Chris Lattner2006-02-121-6/+135
| | | | | | | | | | | | | 1. Teach GetConstantInType to handle boolean constants. 2. Teach instcombine to fold (compare X, CST) when X has known 0/1 bits. Testcase here: set.ll:test22 3. Improve the "(X >> c1) & C2 == 0" folding code to allow a noop cast between the shift and and. More aggressive bitfolding for other reasons was turning signed shr's into unsigned shr's, leaving the noop cast in the way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26131 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert my last patch. It too breaks stuffChris Lattner2006-02-121-12/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26128 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for my previously reverted patchChris Lattner2006-02-111-6/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26126 91177308-0d34-0410-b5e6-96231b3b80d8
* Port the recent innovations in ComputeMaskedBits to SimplifyDemandedBits.Chris Lattner2006-02-111-211/+425
| | | | | | | | | | | | This allows us to simplify on conditions where bits are not known, but they are not demanded either! This also fixes a couple of bugs in ComputeMaskedBits that were exposed during this work. In the future, swaths of instcombine should be removed, as this code subsumes a bunch of ad-hockery. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26122 91177308-0d34-0410-b5e6-96231b3b80d8
* revert my previous change, it exposed other problems.Chris Lattner2006-02-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26121 91177308-0d34-0410-b5e6-96231b3b80d8