summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Propagate TargetLibraryInfo throughout ConstantFolding.cpp and Chad Rosier2011-12-011-2/+9
| | | | | | | InstructionSimplify.cpp. Other fixups as needed. Part of rdar://10500969 llvm-svn: 145559
* Fold two identical set lookups into one. No functionality change.Nick Lewycky2011-09-291-4/+2
| | | | llvm-svn: 140821
* Stop emitting instructions with the name "tmp" they eat up memory and have ↵Benjamin Kramer2011-09-271-1/+1
| | | | | | | | to be uniqued, without any benefit. If someone prefers %tmp42 to %42, run instnamer. llvm-svn: 140634
* Use IRBuilder.Devang Patel2011-09-061-17/+14
| | | | llvm-svn: 139156
* Dramatically speedup codegen prepare by a) avoiding use of dominator tree ↵Devang Patel2011-08-181-16/+38
| | | | | | and b) doing a separate pass over dbg.value instructions. llvm-svn: 137908
* Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'Bill Wendling2011-08-161-13/+6
| | | | | | check for a LandingPadInst. llvm-svn: 137745
* In places where it's using "getFirstNonPHI", skip the landingpad instruction ↵Bill Wendling2011-08-151-5/+8
| | | | | | if necessary. llvm-svn: 137679
* Skip the insertion iterator past the landingpad instruction if there.Bill Wendling2011-08-151-0/+1
| | | | llvm-svn: 137626
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-4/+4
| | | | llvm-svn: 135375
* Fix warnings due to 132263; Thanks rdivacky.Nadav Rotem2011-05-291-2/+4
| | | | llvm-svn: 132285
* Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'Nadav Rotem2011-05-271-2/+2
| | | | | | code in one place. Re-apply 131534 and fix the multi-step promotion of integers. llvm-svn: 132217
* Fix warning about || and && without explicit grouping.Chandler Carruth2011-05-261-2/+2
| | | | | | | | This looks like it flagged an actual bug. Devang, please review. I added the parentheses that change behavior, but make the behavior more closely match commit log's intent. llvm-svn: 132165
* Do not insert anything after terminator.Devang Patel2011-05-261-1/+2
| | | | llvm-svn: 132164
* Do not move DBG_VALUE in middle of PHI nodes.Devang Patel2011-05-261-1/+4
| | | | llvm-svn: 132161
* If llvm.dbg.value and the value instruction it refers to are far apart then ↵Devang Patel2011-05-261-1/+13
| | | | | | iSel may not be able to find corresponding Node for llvm.dbg.value during DAG construction. Make iSel's life easier by removing this distance between llvm.dbg.value and its value instruction. llvm-svn: 132151
* Add a parameter to ConstantFoldTerminator() that callers can use to ask it ↵Frits van Bommel2011-05-221-1/+1
| | | | | | | | to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior. I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this. llvm-svn: 131855
* Revert commit 131534 since it seems to have broken several buildbots.Duncan Sands2011-05-181-2/+2
| | | | | | | | Original log entry: Refactor getActionType and getTypeToTransformTo ; place all of the 'decision' code in one place. llvm-svn: 131536
* Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'Nadav Rotem2011-05-181-2/+2
| | | | | | code in one place. llvm-svn: 131534
* Fix a bug where RecursivelyDeleteTriviallyDeadInstructions couldChris Lattner2011-04-091-3/+18
| | | | | | | delete the instruction pointed to by CGP's current instruction iterator, leading to a crash on the testcase. This fixes PR9578. llvm-svn: 129200
* Debug intrinsics must be skipped at the beginning and ends of blocks, lest theyCameron Zwarich2011-03-241-2/+6
| | | | | | affect the generated code. llvm-svn: 128217
* It is enough for the CallInst to have no uses to be made a tail call with a retCameron Zwarich2011-03-241-1/+1
| | | | | | void; it doesn't need to have a void type. llvm-svn: 128212
* s/UpdateDT/ModifiedDT/gDevang Patel2011-03-241-8/+8
| | | | llvm-svn: 128211
* Do early taildup of ret in CodeGenPrepare for potential tail calls that have aCameron Zwarich2011-03-241-17/+37
| | | | | | void return type. This fixes PR9487. llvm-svn: 128197
* Use an early return instead of a long if block.Cameron Zwarich2011-03-241-51/+51
| | | | llvm-svn: 128196
* When UpdateDT is set, DT is invalid, which could cause problems when trying toCameron Zwarich2011-03-241-2/+3
| | | | | | use it later. I couldn't make a test that hits this with the current code. llvm-svn: 128195
* Check for TLI so that -codegenprepare can be used from opt.Cameron Zwarich2011-03-241-0/+3
| | | | llvm-svn: 128194
* Re-apply r127953 with fixes: eliminate empty return block if it has no ↵Evan Cheng2011-03-211-10/+122
| | | | | | predecessors; update dominator tree if cfg is modified. llvm-svn: 127981
* Revert r127953, "SimplifyCFG has stopped duplicating returns into predecessorsDaniel Dunbar2011-03-191-99/+4
| | | | | | to canonicalize IR", it broke a lot of things. llvm-svn: 127954
* SimplifyCFG has stopped duplicating returns into predecessors to canonicalize IREvan Cheng2011-03-191-4/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to have single return block (at least getting there) for optimizations. This is general goodness but it would prevent some tailcall optimizations. One specific case is code like this: int f1(void); int f2(void); int f3(void); int f4(void); int f5(void); int f6(void); int foo(int x) { switch(x) { case 1: return f1(); case 2: return f2(); case 3: return f3(); case 4: return f4(); case 5: return f5(); case 6: return f6(); } } => LBB0_2: ## %sw.bb callq _f1 popq %rbp ret LBB0_3: ## %sw.bb1 callq _f2 popq %rbp ret LBB0_4: ## %sw.bb3 callq _f3 popq %rbp ret This patch teaches codegenprep to duplicate returns when the return value is a phi and where the phi operands are produced by tail calls followed by an unconditional branch: sw.bb7: ; preds = %entry %call8 = tail call i32 @f5() nounwind br label %return sw.bb9: ; preds = %entry %call10 = tail call i32 @f6() nounwind br label %return return: %retval.0 = phi i32 [ %call10, %sw.bb9 ], [ %call8, %sw.bb7 ], ... [ 0, %entry ] ret i32 %retval.0 This allows codegen to generate better code like this: LBB0_2: ## %sw.bb jmp _f1 ## TAILCALL LBB0_3: ## %sw.bb1 jmp _f2 ## TAILCALL LBB0_4: ## %sw.bb3 jmp _f3 ## TAILCALL rdar://9147433 llvm-svn: 127953
* Roll r127459 back in:Cameron Zwarich2011-03-111-0/+14
| | | | | | | | | | | Optimize trivial branches in CodeGenPrepare, which often get created from the lowering of objectsize intrinsics. Unfortunately, a number of tests were relying on llc not optimizing trivial branches, so I had to add an option to allow them to continue to test what they originally tested. This fixes <rdar://problem/8785296> and <rdar://problem/9112893>. llvm-svn: 127498
* Revert r127459, "Optimize trivial branches in CodeGenPrepare, which often getDaniel Dunbar2011-03-111-14/+0
| | | | | | created from the", it broke some GCC test suite tests. llvm-svn: 127477
* Optimize trivial branches in CodeGenPrepare, which often get created from theCameron Zwarich2011-03-111-0/+14
| | | | | | | | | | lowering of objectsize intrinsics. Unfortunately, a number of tests were relying on llc not optimizing trivial branches, so I had to add an option to allow them to continue to test what they originally tested. This fixes <rdar://problem/8785296> and <rdar://problem/9112893>. llvm-svn: 127459
* Fix PR9398 - 10% of llc compile time is spent in Value::getNumUses. This reducesCameron Zwarich2011-03-051-7/+22
| | | | | | | the percentage of time spent in CodeGenPrepare when llcing 403.gcc from 12.6% to 1.8% of total llc time. llvm-svn: 127069
* Remove some more unused code that I missed.Cameron Zwarich2011-03-021-19/+0
| | | | llvm-svn: 126826
* Eliminate the unused CodeGenPrepare option to split critical edges.Cameron Zwarich2011-03-021-128/+1
| | | | llvm-svn: 126825
* Stop computing the number of uses twice per value in CodeGenPrepare's sinking ofCameron Zwarich2011-03-011-3/+4
| | | | | | | | addressing code. On 403.gcc this almost halves CodeGenPrepare time and reduces total llc time by 9.5%. Unfortunately, getNumUses() is still the hottest function in llc. llvm-svn: 126782
* fix rdar://8878965, a regression I introduced with the recentChris Lattner2011-01-181-1/+3
| | | | | | llvm.objectsize changes. llvm-svn: 123771
* temporarily revert r123526. While working on a follow-on patch IChris Lattner2011-01-151-3/+0
| | | | | | realize that ConstantFoldTerminator doesn't preserve dominfo. llvm-svn: 123527
* fix rdar://8785296 - -fcatch-undefined-behavior generates inefficient codeChris Lattner2011-01-151-0/+3
| | | | | | | | | The basic issue is that isel (very reasonably!) expects conditional branches to be folded, so CGP leaving around a bunch dead computation feeding conditional branches isn't such a good idea. Just fold branches on constants into unconditional branches. llvm-svn: 123526
* simplify code, no functionality change.Chris Lattner2011-01-151-30/+37
| | | | llvm-svn: 123525
* Now that instruction optzns can update the iterator as they go, we can Chris Lattner2011-01-151-10/+16
| | | | | | | | have objectsize folding recursively simplify away their result when it folds. It is important to catch this here, because otherwise we won't eliminate the cross-block values at isel and other times. llvm-svn: 123524
* make the current instruction iterator an ivar, allowing xforms thatChris Lattner2011-01-151-35/+38
| | | | | | | potentially invalidate it (like inline asm lowering) to be sunk into their proper place, cleaning up a ton of code. llvm-svn: 123523
* Make more passes preserve dominators (or state that they preserve dominators ifCameron Zwarich2011-01-081-0/+11
| | | | | | | | | | they all ready do). This removes two dominator recomputations prior to isel, which is a 1% improvement in total llc time for 403.gcc. The only potentially suspect thing is making GCStrategy recompute dominators if it used a custom lowering strategy. llvm-svn: 123064
* Add the CallInst optimizations that don't involve expanding inline assembly toCameron Zwarich2011-01-061-0/+7
| | | | | | OptimizeInst() so that they can be used on a worklist instruction. llvm-svn: 122945
* Move the GEP handling in CodeGenPrepare to OptimizeInst().Cameron Zwarich2011-01-061-12/+12
| | | | llvm-svn: 122944
* Split the optimizations in CodeGenPrepare that don't manipulate the iteratorsCameron Zwarich2011-01-061-41/+52
| | | | | | | into a separate function, so that it can be called from a loop using a worklist rather than a loop traversing a whole basic block. llvm-svn: 122943
* Stop reallocating SunkAddrs for each basic block. When we move to an instructionCameron Zwarich2011-01-061-4/+10
| | | | | | worklist, the key will need to become std::pair<BasicBlock*, Value*>. llvm-svn: 122932
* Add some more statistics to CodeGenPrepare.Cameron Zwarich2011-01-051-0/+4
| | | | llvm-svn: 122891
* Add some stats to CodeGenPrepare to make it easier to speed it up withoutCameron Zwarich2011-01-051-3/+15
| | | | | | regressing code quality. llvm-svn: 122887
* Avoid finding loop back edges when we are not splitting critical edges inCameron Zwarich2011-01-041-2/+4
| | | | | | CodeGenPrepare (which is the default behavior). llvm-svn: 122801
OpenPOWER on IntegriCloud