summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
Commit message (Collapse)AuthorAgeFilesLines
* Speed up instsimplify by about 10-15% by not bothering to retryDuncan Sands2011-01-031-8/+19
| | | | | | | InstructionSimplify on instructions that didn't change since the last time round the loop. llvm-svn: 122745
* split dom frontier handling stuff out to its own DominanceFrontier header,Chris Lattner2011-01-027-29/+18
| | | | | | so that Dominators.h is *just* domtree. Also prune #includes a bit. llvm-svn: 122714
* Fix PR8702 by not having LoopSimplify claim to preserve LCSSA form. As ↵Duncan Sands2011-01-021-15/+12
| | | | | | | | | | described in the PR, the pass could break LCSSA form when inserting preheaders. It probably would be easy enough to fix this, but since currently we always go into LCSSA form after running this pass, doing so is not urgent. llvm-svn: 122695
* Simplify this pass by using a depth-first iterator to ensure that allDuncan Sands2010-12-311-39/+20
| | | | | | operands are visited before the instructions themselves. llvm-svn: 122647
* Zap dead instructions harder.Duncan Sands2010-12-311-7/+2
| | | | llvm-svn: 122645
* Make a bunch of symbols internal.Benjamin Kramer2010-12-301-1/+2
| | | | llvm-svn: 122642
* BuildLibCalls: Nuke EmitMemCpy, EmitMemMove and EmitMemSet. They are dead ↵Benjamin Kramer2010-12-271-49/+5
| | | | | | and superseded by IRBuilder. llvm-svn: 122576
* don't lose TD infoChris Lattner2010-12-251-1/+1
| | | | llvm-svn: 122556
* switch the inliner alignment enforcement stuff to use theChris Lattner2010-12-251-27/+8
| | | | | | | getOrEnforceKnownAlignment function, which simplifies the code and makes it stronger. llvm-svn: 122555
* Move getOrEnforceKnownAlignment out of instcombine into Transforms/Utils.Chris Lattner2010-12-251-0/+92
| | | | llvm-svn: 122554
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-232-2/+2
| | | | | | | new gcc warning that complains on self-assignments and self-initializations. llvm-svn: 122458
* Visit instructions deterministically. Use a FIFO so as to approximatelyDuncan Sands2010-12-211-11/+21
| | | | | | | visit instructions before their uses, since InstructionSimplify does a better job in that case. All this prompted by Frits van Bommel. llvm-svn: 122343
* If an instruction simplifies, try again to simplify any uses of it. This isDuncan Sands2010-12-211-4/+32
| | | | | | | not very important since the pass is only used for testing, but it does make it more realistic. Suggested by Frits van Bommel. llvm-svn: 122336
* Oops, forgot to add the pass itself!Duncan Sands2010-12-201-0/+69
| | | | llvm-svn: 122265
* Add a new convenience pass for testing InstructionSimplify. PreviouslyDuncan Sands2010-12-202-0/+2
| | | | | | | | | it could only be tested indirectly, via instcombine, gvn or some other pass that makes use of InstructionSimplify, which means that testcases had to be carefully contrived to dance around any other transformations that that pass did. llvm-svn: 122264
* when eliding a byval copy due to inlining a readonly function, we haveChris Lattner2010-12-201-4/+43
| | | | | | to make sure that the reused alloca has sufficient alignment. llvm-svn: 122236
* pull byval processing out to its own helper function.Chris Lattner2010-12-201-56/+72
| | | | llvm-svn: 122235
* fix PR8769, a miscompilation by inliner when inlining a function with a byvalChris Lattner2010-12-201-6/+10
| | | | | | | | argument. The generated alloca has to have at least the alignment of the byval, if not, the client may be making assumptions that the new alloca won't satisfy. llvm-svn: 122234
* 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
* remove the dead (and terrible) llvm::RemoveSuccessor function.Chris Lattner2010-12-141-46/+0
| | | | llvm-svn: 121753
* 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
* fix a bug in r121680 that upset the various buildbots.Chris Lattner2010-12-131-0/+7
| | | | llvm-svn: 121687
* refactor the speculative execution logic to be factored into the cond branch ↵Chris Lattner2010-12-131-26/+22
| | | | | | | | code instead of doing a cfg search for every block simplified. llvm-svn: 121686
* simplify a bunch of code.Chris Lattner2010-12-131-15/+4
| | | | llvm-svn: 121685
* move HoistThenElseCodeToIf up to a more logical and efficient-to-handle place.Chris Lattner2010-12-131-7/+11
| | | | llvm-svn: 121684
* move 'MergeBlocksIntoPredecessor' call earlier. UseChris Lattner2010-12-131-20/+9
| | | | | | getSinglePredecessor to simplify code. llvm-svn: 121683
* factor new code out to a SimplifyBranchOnICmpChain helper function.Chris Lattner2010-12-131-77/+91
| | | | llvm-svn: 121681
* enhance the "change or icmp's into switch" xform to handle one value in an Chris Lattner2010-12-131-3/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'or sequence' that it doesn't understand. This allows us to optimize something insane like this: int crud (unsigned char c, unsigned x) { if(((((((((( (int) c <= 32 || (int) c == 46) || (int) c == 44) || (int) c == 58) || (int) c == 59) || (int) c == 60) || (int) c == 62) || (int) c == 34) || (int) c == 92) || (int) c == 39) != 0) foo(); } into: define i32 @crud(i8 zeroext %c, i32 %x) nounwind ssp noredzone { entry: %cmp = icmp ult i8 %c, 33 br i1 %cmp, label %if.then, label %switch.early.test switch.early.test: ; preds = %entry switch i8 %c, label %if.end [ i8 39, label %if.then i8 44, label %if.then i8 58, label %if.then i8 59, label %if.then i8 60, label %if.then i8 62, label %if.then i8 46, label %if.then i8 92, label %if.then i8 34, label %if.then ] by pulling the < comparison out ahead of the newly formed switch. llvm-svn: 121680
OpenPOWER on IntegriCloud