summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
* SimplifyCFG: Expose phi node folding cost threshold as command line parameterPeter Collingbourne2011-04-291-1/+6
| | | | llvm-svn: 130528
* SimplifyCFG: Add CostRemaining parameter to DominatesMergePointPeter Collingbourne2011-04-291-9/+38
| | | | llvm-svn: 130527
* SimplifyCFG: Add Trunc, ZExt and SExt to the list of cheap instructions for ↵Peter Collingbourne2011-04-291-0/+3
| | | | | | phi node folding llvm-svn: 130526
* rework FoldBranchToCommonDest to exit earlier when there is a bonusChris Lattner2011-04-141-39/+30
| | | | | | | | | | | | instruction around, reducing work. Greatly simplify handling of debug instructions. There is no need to build up a vector of them and then move them into the one predecessor if we're processing a block. Instead just rescan the block and *copy* them into the pred. If a block gets merged into multiple preds, this will retain more debug info. llvm-svn: 129502
* comment cleanup, use moveBefore instead of removeFromParent+insertBefore.Chris Lattner2011-04-111-9/+5
| | | | llvm-svn: 129319
* Do not let debug info interfer with branch folding.Devang Patel2011-04-071-0/+6
| | | | llvm-svn: 129114
* While hoisting common code from if/else, hoist debug info intrinsics if they ↵Devang Patel2011-04-071-8/+18
| | | | | | match. llvm-svn: 129078
* Simplify. isIdenticalToWhenDefined() checks opcode.Devang Patel2011-04-071-4/+2
| | | | llvm-svn: 129041
* While folding branch to a common destination into a predecessor, copy dbg ↵Devang Patel2011-04-061-4/+17
| | | | | | values also. llvm-svn: 129035
* Remove PHINode::reserveOperandSpace(). Instead, add a parameter toJay Foad2011-03-301-1/+1
| | | | | | PHINode::Create() giving the (known or expected) number of operands. llvm-svn: 128537
* (Almost) always call reserveOperandSpace() on newly created PHINodes.Jay Foad2011-03-301-1/+3
| | | | llvm-svn: 128535
* PR9450: Make switch optimization in SimplifyCFG not dependent on the orderingEli Friedman2011-03-151-7/+18
| | | | | | of pointers in an std::map. llvm-svn: 127650
* PR9420; an instruction before an unreachable is guaranteed not to have anyEli Friedman2011-03-091-1/+3
| | | | | | | | reachable uses, but there still might be uses in dead blocks. Use the standard solution of replacing all the uses with undef. This is a rare case because it's very sensitive to phase ordering in SimplifyCFG. llvm-svn: 127299
* Teach SimplifyCFG that (switch (select cond, X, Y)) is better expressed as a ↵Frits van Bommel2011-02-281-1/+26
| | | | | | | | branch. Based on a patch by Alistair Lynn. llvm-svn: 126647
* Revert "SimplifyCFG: GEPs with just one non-constant index are also cheap."Benjamin Kramer2011-02-251-5/+3
| | | | | | | Yes, there are other types than i8* and GEPs on them can produce an add+multiply. We don't consider that cheap enough to be speculatively executed. llvm-svn: 126481
* SimplifyCFG: GEPs with just one non-constant index are also cheap.Benjamin Kramer2011-02-241-3/+5
| | | | llvm-svn: 126452
* SimplifyCFG: GEPs with constant indices are cheap enough to be executed ↵Benjamin Kramer2011-02-241-0/+5
| | | | | | unconditionally. llvm-svn: 126445
* SimplifyCFG: Track the number of used icmps when turning a icmp chain into a ↵Benjamin Kramer2011-02-071-7/+22
| | | | | | | | switch. If we used only one icmp, don't turn it into a switch. Also prevent the switch-to-icmp transform from creating identity adds, noticed by Marius Wachtler. llvm-svn: 125056
* SimplifyCFG: Also transform switches that represent a range comparison but ↵Benjamin Kramer2011-02-031-6/+17
| | | | | | | | are not sorted into sub+icmp. This transforms another 1000 switches in gcc.c. llvm-svn: 124826
* SimplifyCFG: Turn switches into sub+icmp+branch if possible.Benjamin Kramer2011-02-021-0/+32
| | | | | | | | | | | | | | | | | This makes the job of the later optzn passes easier, allowing the vast amount of icmp transforms to chew on it. We transform 840 switches in gcc.c, leading to a 16k byte shrink of the resulting binary on i386-linux. The testcase from README.txt now compiles into decl %edi cmpl $3, %edi sbbl %eax, %eax andl $1, %eax ret llvm-svn: 124724
* Re-apply r124518 with fix. Watch out for invalidated iterator.Evan Cheng2011-01-291-18/+7
| | | | llvm-svn: 124526
* Revert r124518. It broke Linux self-host.Evan Cheng2011-01-291-7/+18
| | | | llvm-svn: 124522
* Re-commit r124462 with fixes. Tail recursion elim will now dup ret into ↵Evan Cheng2011-01-291-18/+7
| | | | | | unconditional predecessor to enable TCE on demand. llvm-svn: 124518
* Revert r124462. There are a few big regressions that I need to fix first.Evan Cheng2011-01-281-6/+1
| | | | llvm-svn: 124478
* - Stop simplifycfg from duplicating "ret" instructions into unconditionalEvan Cheng2011-01-281-1/+6
| | | | | | | | branches. PR8575, rdar://5134905, rdar://8911460. - Allow codegen tail duplication to dup small return blocks after register allocation is done. llvm-svn: 124462
* Factor the actual simplification out of SimplifyIndirectBrOnSelect and into ↵Frits van Bommel2011-01-111-26/+37
| | | | | | | | a new helper function so it can be reused in e.g. an upcoming SimplifySwitchOnSelect. No functional change. llvm-svn: 123234
* simplify this a bit.Chris Lattner2010-12-181-2/+1
| | | | llvm-svn: 122156
* SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build.Benjamin Kramer2010-12-171-1/+1
| | | | llvm-svn: 122054
* improve switch formation to handle small range Chris Lattner2010-12-171-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | comparisons formed by comparisons. For example, this: void foo(unsigned x) { if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6) bar(); } compiles into: _foo: ## @foo ## BB#0: ## %entry cmpl $6, %edi ja LBB0_2 ## BB#1: ## %entry movl %edi, %eax movl $91, %ecx btq %rax, %rcx jb LBB0_3 instead of: _foo: ## @foo ## BB#0: ## %entry cmpl $2, %edi jb LBB0_4 ## BB#1: ## %switch.early.test cmpl $6, %edi ja LBB0_3 ## BB#2: ## %switch.early.test movl %edi, %eax movl $88, %ecx btq %rax, %rcx jb LBB0_4 This catches a bunch of cases in GCC, which look like this: %804 = load i32* @which_alternative, align 4, !tbaa !0 %805 = icmp ult i32 %804, 2 %806 = icmp eq i32 %804, 3 %or.cond121 = or i1 %805, %806 %807 = icmp eq i32 %804, 4 %or.cond124 = or i1 %or.cond121, %807 br i1 %or.cond124, label %.thread, label %808 turning this into a range comparison. llvm-svn: 122045
* make qsort predicate more conformant by returning 0 for equal values.Chris Lattner2010-12-151-1/+5
| | | | llvm-svn: 121838
* - Insert new instructions before DomBlock's terminator,Chris Lattner2010-12-141-7/+16
| | | | | | | | | | which is simpler than finding a place to insert in BB. - Don't perform the 'if condition hoisting' xform on certain i1 PHIs, as it interferes with switch formation. This re-fixes "example 7", without breaking the world hopefully. llvm-svn: 121764
* fix two significant issues with FoldTwoEntryPHINode:Chris Lattner2010-12-141-1/+11
| | | | | | | | | | | | | first, it can kick in on blocks whose conditions have been folded to a constant, even though one of the edges will be trivially folded. second, it doesn't clean up the "if diamond" that it just eliminated away. This is a problem because other simplifycfg xforms kick in depending on the order of block visitation, causing pointless work. llvm-svn: 121762
* remove the instsimplify logic I added in r121754. It is apparentlyChris Lattner2010-12-141-11/+1
| | | | | | breaking the selfhost builds, though I can't fathom how. llvm-svn: 121761
* clean up logic, convert std::set to SmallPtrSet, handle the caseChris Lattner2010-12-141-56/+61
| | | | | | when all 2-entry phis are simplified away. llvm-svn: 121760
* tidy up a bit, move DEBUG down to when we commit to doing the transform so we Chris Lattner2010-12-141-7/+5
| | | | | | don't print it unless the xform happens. llvm-svn: 121758
* use SimplifyInstruction instead of reimplementing part of it.Chris Lattner2010-12-141-10/+7
| | | | llvm-svn: 121757
* simplify GetIfCondition by using getSinglePredecessor.Chris Lattner2010-12-141-28/+24
| | | | llvm-svn: 121756
* use AddPredecessorToBlock in 3 places instead of a manual loop.Chris Lattner2010-12-141-18/+6
| | | | llvm-svn: 121755
* make FoldTwoEntryPHINode use instsimplify a bit, makeChris Lattner2010-12-141-12/+21
| | | | | | | GetIfCondition faster by avoiding pred_iterator. No really interesting change. llvm-svn: 121754
* improve DEBUG's a bit, switch to eraseFromParent() to simplifyChris Lattner2010-12-141-26/+28
| | | | | | code a bit, switch from constant folding to instsimplify. llvm-svn: 121751
* reapply my recent change that disables a piece of the switch formationChris Lattner2010-12-141-5/+13
| | | | | | work, but fixes 400.perlbmk. llvm-svn: 121749
* Fix recent buildbot breakage by pulling SimplifyCFG back to its state as of ↵Owen Anderson2010-12-131-14/+6
| | | | | | | | r121694, the most recent state where I'm confident there were no crashes or miscompilations. XFAIL the test added since then for now. llvm-svn: 121733
* temporarily disable part of my previous patch, which causes an iterator ↵Chris Lattner2010-12-131-1/+1
| | | | | | invalidation issue, causing a crash on some versions of perlbmk. llvm-svn: 121728
* add some DEBUG's.Chris Lattner2010-12-131-3/+8
| | | | llvm-svn: 121711
* Fix sort predicate. qsort(3)'s predicate semantics differ from std::sort's. ↵Benjamin Kramer2010-12-131-1/+1
| | | | | | Fixes PR 8780. llvm-svn: 121705
* reinstate my patch: the miscompile was caused by an inverted branch in theChris Lattner2010-12-131-3/+6
| | | | | | 'and' case. llvm-svn: 121695
* Completely disable the optimization I added in r121680 untilChris Lattner2010-12-131-3/+6
| | | | | | | I can track down a miscompile. This should bring the buildbots back to life llvm-svn: 121693
* Make simplifycfg reprocess newly formed "br (cond1 | cond2)" conditionsChris Lattner2010-12-131-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when simplifying, allowing them to be eagerly turned into switches. This is the last step required to get "Example 7" from this blog post: http://blog.regehr.org/archives/320 On X86, we now generate this machine code, which (to my eye) seems better than the ICC generated code: _crud: ## @crud ## BB#0: ## %entry cmpb $33, %dil jb LBB0_4 ## BB#1: ## %switch.early.test addb $-34, %dil cmpb $58, %dil ja LBB0_3 ## BB#2: ## %switch.early.test movzbl %dil, %eax movabsq $288230376537592865, %rcx ## imm = 0x400000017001421 btq %rax, %rcx jb LBB0_4 LBB0_3: ## %lor.rhs xorl %eax, %eax ret LBB0_4: ## %lor.end movl $1, %eax ret llvm-svn: 121690
* make this logic a bit simpler.Chris Lattner2010-12-131-21/+20
| | | | llvm-svn: 121689
* split all the guts of SimplifyCFGOpt::run out into one functionChris Lattner2010-12-131-374/+441
| | | | | | per terminator kind. llvm-svn: 121688
OpenPOWER on IntegriCloud