summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
Commit message (Collapse)AuthorAge
* third bug from PR6119: the xor dupe extension allowsChris Lattner2010-01-23
| | | | | | | | | for arbitrary terminators in predecessors, don't assume it is a conditional or uncond branch. The testcase shows an example where they can happen with switches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94323 91177308-0d34-0410-b5e6-96231b3b80d8
* add an early out to ProcessBranchOnXOR to speed it up,Chris Lattner2010-01-23
| | | | | | | | | handle the case when we can infer an input to the xor from all inputs that agree, instead of going into an infinite loop. Another part of PR6199 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94321 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a crash in jump threading, PR6119Chris Lattner2010-01-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94319 91177308-0d34-0410-b5e6-96231b3b80d8
* 1) Use the new SimplifyInstructionsInBlock routine instead of the copyChris Lattner2010-01-12
| | | | | | | | | | | | | in JT. 2) When cloning blocks for PHI or xor conditions, use instsimplify to simplify the code as we go. This allows us to squish common cases early in JT which opens up opportunities for subsequent iterations, and allows it to completely simplify the testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93253 91177308-0d34-0410-b5e6-96231b3b80d8
* tidy upChris Lattner2010-01-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93222 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach jump threading to duplicate small blocks when the branchChris Lattner2010-01-12
| | | | | | | | | | | | | | | | | | | | | condition is a xor with a phi node. This eliminates nonsense like this from 176.gcc in several places: LBB166_84: testl %eax, %eax - setne %al - xorb %cl, %al - notb %al - testb $1, %al - je LBB166_85 + je LBB166_69 + jmp LBB166_85 This is rdar://7391699 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93221 91177308-0d34-0410-b5e6-96231b3b80d8
* some cleanup, and make it obvious that ProcessJumpOnPHI only worksChris Lattner2010-01-11
| | | | | | | on branches by renaming it and checking for a branch at the call site. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93208 91177308-0d34-0410-b5e6-96231b3b80d8
* Use a do-while loop instead of while + boolean.Benjamin Kramer2010-01-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92912 91177308-0d34-0410-b5e6-96231b3b80d8
* Change errs() to dbgs().David Greene2010-01-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92614 91177308-0d34-0410-b5e6-96231b3b80d8
* Metadata.h doesn't need to include ValueHandle.h anymore.Chris Lattner2009-12-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92211 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR5698Chris Lattner2009-12-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90708 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR5640 by tracking whether a block is the header of a loop moreChris Lattner2009-12-01
| | | | | | | precisely, which prevents us from infinitely peeling the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90211 91177308-0d34-0410-b5e6-96231b3b80d8
* make PRE of loads preserve the alignment of the moved load instruction.Chris Lattner2009-11-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88865 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bug handling 'not x' when x is undef.Chris Lattner2009-11-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88864 91177308-0d34-0410-b5e6-96231b3b80d8
* use getPredicateOnEdge to fold comparisons through PHI nodes,Chris Lattner2009-11-12
| | | | | | | | which implements GCC PR18046. This also gets us 360 more jump threads on 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86953 91177308-0d34-0410-b5e6-96231b3b80d8
* various fixes to the lattice transfer functions.Chris Lattner2009-11-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86952 91177308-0d34-0410-b5e6-96231b3b80d8
* switch jump threading to use getPredicateOnEdge in one placeChris Lattner2009-11-12
| | | | | | | | | making the new LVI stuff smart enough to subsume some special cases in the old code. Disable them when LVI is around, the testcase still passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86951 91177308-0d34-0410-b5e6-96231b3b80d8
* with the new code we can thread non-instruction values. ThisChris Lattner2009-11-12
| | | | | | | allows us to handle the test10 testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86924 91177308-0d34-0410-b5e6-96231b3b80d8
* this argument can be an arbitrary value, it doesn't need to be an instruction.Chris Lattner2009-11-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86923 91177308-0d34-0410-b5e6-96231b3b80d8
* expose edge information and switch j-t to use it.Chris Lattner2009-11-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86920 91177308-0d34-0410-b5e6-96231b3b80d8
* pass TD into a SimplifyCmpInst call. Add another case thatChris Lattner2009-11-11
| | | | | | | uses LVI info when -enable-jump-threading-lvi is passed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86886 91177308-0d34-0410-b5e6-96231b3b80d8
* stub out some LazyValueInfo interfaces, and have JumpThreadingChris Lattner2009-11-11
| | | | | | | | | start using them in a trivial way when -enable-jump-threading-lvi is passed. enable-jump-threading-lvi will be my playground for awhile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86789 91177308-0d34-0410-b5e6-96231b3b80d8
* add a fixmeChris Lattner2009-11-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86766 91177308-0d34-0410-b5e6-96231b3b80d8
* implement a TODO by teaching jump threading about "xor x, 1".Chris Lattner2009-11-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86739 91177308-0d34-0410-b5e6-96231b3b80d8
* move some generally useful functions out of jump threadingChris Lattner2009-11-10
| | | | | | | into libanalysis and transformutils. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86735 91177308-0d34-0410-b5e6-96231b3b80d8
* improve comment.Chris Lattner2009-11-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86723 91177308-0d34-0410-b5e6-96231b3b80d8
* Make jump threading eliminate blocks that just contain phi nodes,Chris Lattner2009-11-10
| | | | | | | | | debug intrinsics, and an unconditional branch when possible. This reuses the TryToSimplifyUncondBranchFromEmptyBlock function split out of simplifycfg. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86722 91177308-0d34-0410-b5e6-96231b3b80d8
* make jump threading recursively simplify expressions instead of doing it Chris Lattner2009-11-10
| | | | | | | | | | | | | | | | | | | | | just one level deep. On the testcase we go from getting this: F1: ; preds = %T2 %F = and i1 true, %cond ; <i1> [#uses=1] br i1 %F, label %X, label %Y to a fully threaded: F1: ; preds = %T2 br label %Y This changes gets us to the point where we're forming (too many) switch instructions on doug's strswitch testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86646 91177308-0d34-0410-b5e6-96231b3b80d8
* don't invalidate PN, rewrite of this code is in progress anyway.Chris Lattner2009-11-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86639 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new SimplifyInstruction API, which is like ConstantFoldInstruction, Chris Lattner2009-11-10
| | | | | | | | | except that the result may not be a constant. Switch jump threading to use it so that it gets things like (X & 0) -> 0, which occur when phi preds are deleted and the remaining phi pred was a zero. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86637 91177308-0d34-0410-b5e6-96231b3b80d8
* rename SimplifyCompare -> SimplifyCmpInst and split it into Chris Lattner2009-11-09
| | | | | | | | Simplify[IF]Cmp pieces. Add some predicates to CmpInst to determine whether a predicate is fp or int. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86624 91177308-0d34-0410-b5e6-96231b3b80d8
* use instructionsimplify instead of a weak clone of ad-hoc folding stuff.Chris Lattner2009-11-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86616 91177308-0d34-0410-b5e6-96231b3b80d8
* stub out a new form of BasicBlock::RemovePredecessorAndSimplify whichChris Lattner2009-11-09
| | | | | | | | simplifies instruction users of PHIs when the phi is eliminated. This will be moved to transforms/utils after some other refactoring. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86603 91177308-0d34-0410-b5e6-96231b3b80d8
* comment typos pointed out by DuncanChris Lattner2009-11-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86497 91177308-0d34-0410-b5e6-96231b3b80d8
* reapply 86289, 86278, 86270, 86267, 86266 & 86264 plus a fixChris Lattner2009-11-07
| | | | | | | | | | | (making pred factoring only happen if threading is guaranteed to be successful). This now survives an X86-64 bootstrap of llvm-gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86355 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert following patches to fix llvmgcc bootstrap.Devang Patel2009-11-07
| | | | | | | | | 86289, 86278, 86270, 86267, 86266 & 86264 Chris, please take a look. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86321 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid "ambiguous 'else'" warning from gcc.Jeffrey Yasskin2009-11-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86314 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug where we'd call SplitBlockPredecessors with a pred in the Chris Lattner2009-11-06
| | | | | | | set only once even if it has multiple edges to BB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86299 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove function left over from other jump threading cleanup.Eli Friedman2009-11-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86289 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a problem discovered on self host.Chris Lattner2009-11-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86278 91177308-0d34-0410-b5e6-96231b3b80d8
* remove more code subsumed by r86264Chris Lattner2009-11-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86270 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate some more code subsumed by r86264Chris Lattner2009-11-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86267 91177308-0d34-0410-b5e6-96231b3b80d8
* remove now redundant code, r86264 handles this case.Chris Lattner2009-11-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86266 91177308-0d34-0410-b5e6-96231b3b80d8
* Extend jump threading to support much more general threadingChris Lattner2009-11-06
| | | | | | | | | | | | | | | | | | | | | | | predicates. This allows us to jump thread things like: _ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit119: %tmp1.i24166 = phi i8 [ 1, %bb5.i117 ], [ %tmp1.i24165, %_Z....exit ], [ %tmp1.i24165, %bb4.i114 ] %toBoolnot.i87 = icmp eq i8 %tmp1.i24166, 0 ; <i1> [#uses=1] %tmp4.i90 = icmp eq i32 %tmp2.i, 6 ; <i1> [#uses=1] %or.cond173 = and i1 %toBoolnot.i87, %tmp4.i90 ; <i1> [#uses=1] br i1 %or.cond173, label %bb4.i96, label %_ZN12... Where it is "obvious" that when coming from %bb5.i117 that the 'and' is always false. This triggers a surprisingly high number of times in the testsuite, and gets us closer to generating good code for doug's strswitch testcase. This also make a bunch of other code in jump threading redundant, I'll rip out in the next patch. This survived an enable-checking llvm-gcc bootstrap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86264 91177308-0d34-0410-b5e6-96231b3b80d8
* remove a bunch of extraneous LLVMContext argumentsChris Lattner2009-11-06
| | | | | | | from various APIs, addressing PR5325. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86231 91177308-0d34-0410-b5e6-96231b3b80d8
* improve DSE when TargetData is not around, based on work byChris Lattner2009-11-04
| | | | | | | Hans Wennborg! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86067 91177308-0d34-0410-b5e6-96231b3b80d8
* when folding duplicate conditions, delete the Chris Lattner2009-10-11
| | | | | | | now-probably-dead instruction tree feeding it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83778 91177308-0d34-0410-b5e6-96231b3b80d8
* implement a transformation in jump threading that is currentlyChris Lattner2009-10-11
| | | | | | | | | | | done by condprop, but do it in a much more general form. The basic idea is that we can do a limited form of tail duplication in the case when we have a branch on a phi. Moving the branch up in to the predecessor block makes instruction selection much easier and encourages chained jump threadings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83759 91177308-0d34-0410-b5e6-96231b3b80d8
* restructure some code, no functionality change.Chris Lattner2009-10-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83756 91177308-0d34-0410-b5e6-96231b3b80d8
* factor some code better and move a function, no functionality change.Chris Lattner2009-10-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83755 91177308-0d34-0410-b5e6-96231b3b80d8