Owen Anderson
3c84ecb067
More cleanups of my JumpThreading transforms, including extracting some duplicated code into a helper function.
...
llvm-svn: 112634
2010-08-31 20:26:04 +00:00
Owen Anderson
6fdcb172a9
Add an RAII helper to make cleanup of the RecursionSet more fool-proof.
...
llvm-svn: 112628
2010-08-31 19:24:27 +00:00
Owen Anderson
cd4de7f399
Refactor my fix for PR5652 to terminate the predecessor lookups after the first failure.
...
llvm-svn: 112620
2010-08-31 18:48:48 +00:00
Owen Anderson
3997a07fb9
More Chris-inspired JumpThreading fixes: use ConstantExpr to correctly constant-fold undef, and be more careful with its return value.
...
This actually exposed an infinite recursion bug in ComputeValueKnownInPredecessors which theoretically already existed (in JumpThreading's
handling of and/or of i1's), but never manifested before. This patch adds a tracking set to prevent this case.
llvm-svn: 112589
2010-08-31 07:36:34 +00:00
Owen Anderson
c910acb54a
Re-apply r112539, being more careful to respect the return values of the constant folding methods. Additionally,
...
use the ConstantExpr::get*() methods to simplify some constant folding.
llvm-svn: 112550
2010-08-30 23:22:36 +00:00
Owen Anderson
1ddcbbe49c
Revert r112539. It accidentally introduced a miscompilation.
...
llvm-svn: 112543
2010-08-30 22:33:41 +00:00
Owen Anderson
75f6037c7c
Fixes and cleanups pointed out by Chris. In general, be careful to handle 0 results from ComputeValueKnownInPredecessors
...
(indicating undef), and re-use existing constant folding APIs.
llvm-svn: 112539
2010-08-30 22:07:52 +00:00
Owen Anderson
99d4cb861b
Fix typos in comments.
...
llvm-svn: 112286
2010-08-27 20:32:56 +00:00
Owen Anderson
6ebbd92380
Use LVI to eliminate conditional branches where we've tested a related condition previously. Update tests for this change.
...
This fixes PR5652.
llvm-svn: 112270
2010-08-27 17:12:29 +00:00
Owen Anderson
bd2ecc7e68
Make JumpThreading smart enough to properly thread StrSwitch when it's compiled with clang++.
...
llvm-svn: 112198
2010-08-26 17:40:24 +00:00
Owen Anderson
7c853e877e
Turn LVI on, previously detected failures should be fixed now.
...
llvm-svn: 111923
2010-08-24 17:21:18 +00:00
Owen Anderson
6ffa3f2aea
Turn LVI back off, I have a testcase now.
...
llvm-svn: 111834
2010-08-23 19:59:27 +00:00
Owen Anderson
630add39a6
Re-enable LazyValueInfo. Monitoring for failures.
...
llvm-svn: 111816
2010-08-23 18:12:23 +00:00
Owen Anderson
aac8cbb261
Disable LVI while I evaluate a failure.
...
llvm-svn: 111551
2010-08-19 19:47:08 +00:00
Owen Anderson
5c87dd55d3
Tentatively enabled LVI by default. I'll be monitoring for any failures.
...
llvm-svn: 111543
2010-08-19 19:04:40 +00:00
Owen Anderson
208636fa33
Inform LazyValueInfo whenever a block is deleted, to avoid dangling pointer issues.
...
llvm-svn: 111382
2010-08-18 18:39:01 +00:00
Chris Lattner
3c603024bb
Fix PR7755: knowing something about an inval for a pred
...
from the LHS should disable reconsidering that pred on the
RHS. However, knowing something about the pred on the RHS
shouldn't disable subsequent additions on the RHS from
happening.
llvm-svn: 111349
2010-08-18 03:14:36 +00:00
Owen Anderson
a7aed18624
Reapply r110396, with fixes to appease the Linux buildbot gods.
...
llvm-svn: 110460
2010-08-06 18:33:48 +00:00
Owen Anderson
bda59bd247
Revert r110396 to fix buildbots.
...
llvm-svn: 110410
2010-08-06 00:23:35 +00:00
Owen Anderson
755aceb5d0
Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static
...
ID member as the sole unique type identifier. Clean up APIs related to this change.
llvm-svn: 110396
2010-08-05 23:42:04 +00:00
Owen Anderson
4674dd6cf5
Give JumpThreading+LVI a long-form cl::opt so that it's easier to toggle the default.
...
llvm-svn: 110384
2010-08-05 22:11:31 +00:00
Owen Anderson
aa7f66ba67
Add an initial implementation of LazyValueInfo updating for JumpThreading. Disabled for now.
...
llvm-svn: 109424
2010-07-26 18:48:03 +00:00
Owen Anderson
a57b97e7e7
Fix batch of converting RegisterPass<> to INTIALIZE_PASS().
...
llvm-svn: 109045
2010-07-21 22:09:45 +00:00
Gabor Greif
a5fa885d47
cache results of operator*
...
llvm-svn: 108142
2010-07-12 14:10:24 +00:00
Chris Lattner
bbc25ff5cc
if jump threading is able to infer interesting values on both
...
the LHS and RHS of an and/or instruction, don't multiply add
known predecessor values. This fixes the crash on testcase
from PR7498
llvm-svn: 108114
2010-07-12 00:47:34 +00:00
Chris Lattner
329ea064ed
jump threading can't split a critical edge from an indirectbr. This
...
fixes PR7356.
llvm-svn: 105950
2010-06-14 19:45:43 +00:00
Dan Gohman
826bdf8c10
Move FindAvailableLoadedValue isSafeToLoadUnconditionally out of
...
lib/Transforms/Utils and into lib/Analysis so that Analysis passes
can use them.
llvm-svn: 104949
2010-05-28 16:19:17 +00:00
Chris Lattner
9ae28b141f
fix PR6743, a case where we'd delete an instruction before using it
...
in some cases.
llvm-svn: 100937
2010-04-10 18:26:57 +00:00
Duncan Sands
19d0b47b1f
There are two ways of checking for a given type, for example isa<PointerType>(T)
...
and T->isPointerTy(). Convert most instances of the first form to the second form.
Requested by Chris.
llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Duncan Sands
9dff9bec31
Uniformize the names of type predicates: rather than having isFloatTy and
...
isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris!
llvm-svn: 96223
2010-02-15 16:12:20 +00:00
Chris Lattner
d924f63692
Make jump threading honor x|undef -> true and x&undef -> false,
...
instead of considering x|undef -> x, which may not be true.
llvm-svn: 95850
2010-02-11 04:40:44 +00:00
Chris Lattner
29b15c5cfd
third bug from PR6119: the xor dupe extension allows
...
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.
llvm-svn: 94323
2010-01-23 19:21:31 +00:00
Chris Lattner
ba2d0b89ff
add an early out to ProcessBranchOnXOR to speed it up,
...
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
llvm-svn: 94321
2010-01-23 19:16:25 +00:00
Chris Lattner
de5ab4860f
fix a crash in jump threading, PR6119
...
llvm-svn: 94319
2010-01-23 18:56:07 +00:00
Chris Lattner
573da8ac90
1) Use the new SimplifyInstructionsInBlock routine instead of the copy
...
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.
llvm-svn: 93253
2010-01-12 20:41:47 +00:00
Chris Lattner
af7855d571
tidy up
...
llvm-svn: 93222
2010-01-12 02:07:50 +00:00
Chris Lattner
eb73bdb2e1
Teach jump threading to duplicate small blocks when the branch
...
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
llvm-svn: 93221
2010-01-12 02:07:17 +00:00
Chris Lattner
6a19ed0b86
some cleanup, and make it obvious that ProcessJumpOnPHI only works
...
on branches by renaming it and checking for a branch at the call site.
llvm-svn: 93208
2010-01-11 23:41:09 +00:00
Benjamin Kramer
76e2766442
Use a do-while loop instead of while + boolean.
...
llvm-svn: 92912
2010-01-07 13:50:07 +00:00
David Greene
1efdb45562
Change errs() to dbgs().
...
llvm-svn: 92614
2010-01-05 01:27:19 +00:00
Chris Lattner
f8d22fc77d
Metadata.h doesn't need to include ValueHandle.h anymore.
...
llvm-svn: 92211
2009-12-28 08:20:46 +00:00
Chris Lattner
6d6f10fe91
fix PR5698
...
llvm-svn: 90708
2009-12-06 17:17:23 +00:00
Chris Lattner
3c9aca9079
fix PR5640 by tracking whether a block is the header of a loop more
...
precisely, which prevents us from infinitely peeling the loop.
llvm-svn: 90211
2009-12-01 06:04:43 +00:00
Chris Lattner
9d9812a636
make PRE of loads preserve the alignment of the moved load instruction.
...
llvm-svn: 88865
2009-11-15 19:58:31 +00:00
Chris Lattner
5f037b6439
fix a bug handling 'not x' when x is undef.
...
llvm-svn: 88864
2009-11-15 19:57:43 +00:00
Chris Lattner
5f6b8b2bcb
use getPredicateOnEdge to fold comparisons through PHI nodes,
...
which implements GCC PR18046. This also gets us 360 more
jump threads on 176.gcc.
llvm-svn: 86953
2009-11-12 05:24:05 +00:00
Chris Lattner
22db4b5e0c
various fixes to the lattice transfer functions.
...
llvm-svn: 86952
2009-11-12 04:57:13 +00:00
Chris Lattner
c893c4ed10
switch jump threading to use getPredicateOnEdge in one place
...
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.
llvm-svn: 86951
2009-11-12 04:37:50 +00:00
Chris Lattner
ba45616958
with the new code we can thread non-instruction values. This
...
allows us to handle the test10 testcase.
llvm-svn: 86924
2009-11-12 01:41:34 +00:00
Chris Lattner
3f80d85191
this argument can be an arbitrary value, it doesn't need to be an instruction.
...
llvm-svn: 86923
2009-11-12 01:37:43 +00:00
Chris Lattner
d5e25436a1
expose edge information and switch j-t to use it.
...
llvm-svn: 86920
2009-11-12 01:29:10 +00:00
Chris Lattner
67146695b6
pass TD into a SimplifyCmpInst call. Add another case that
...
uses LVI info when -enable-jump-threading-lvi is passed.
llvm-svn: 86886
2009-11-11 22:31:38 +00:00
Chris Lattner
fde1f8d0d8
stub out some LazyValueInfo interfaces, and have JumpThreading
...
start using them in a trivial way when -enable-jump-threading-lvi
is passed. enable-jump-threading-lvi will be my playground for
awhile.
llvm-svn: 86789
2009-11-11 02:08:33 +00:00
Chris Lattner
3a2ae908fe
add a fixme
...
llvm-svn: 86766
2009-11-11 00:21:58 +00:00
Chris Lattner
9518fbb54e
implement a TODO by teaching jump threading about "xor x, 1".
...
llvm-svn: 86739
2009-11-10 22:39:16 +00:00
Chris Lattner
852d6d64ff
move some generally useful functions out of jump threading
...
into libanalysis and transformutils.
llvm-svn: 86735
2009-11-10 22:26:15 +00:00
Chris Lattner
40b15f220d
improve comment.
...
llvm-svn: 86723
2009-11-10 21:45:09 +00:00
Chris Lattner
80e7e5a429
Make jump threading eliminate blocks that just contain phi nodes,
...
debug intrinsics, and an unconditional branch when possible. This
reuses the TryToSimplifyUncondBranchFromEmptyBlock function split
out of simplifycfg.
llvm-svn: 86722
2009-11-10 21:40:01 +00:00
Chris Lattner
38c44ea6b0
make jump threading recursively simplify expressions instead of doing it
...
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.
llvm-svn: 86646
2009-11-10 01:57:31 +00:00
Chris Lattner
be11db6894
don't invalidate PN, rewrite of this code is in progress anyway.
...
llvm-svn: 86639
2009-11-10 01:19:06 +00:00
Chris Lattner
fb7f87d5a3
add a new SimplifyInstruction API, which is like ConstantFoldInstruction,
...
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.
llvm-svn: 86637
2009-11-10 01:08:51 +00:00
Chris Lattner
c1f19071f8
rename SimplifyCompare -> SimplifyCmpInst and split it into
...
Simplify[IF]Cmp pieces. Add some predicates to CmpInst to
determine whether a predicate is fp or int.
llvm-svn: 86624
2009-11-09 23:28:39 +00:00
Chris Lattner
800aad3dda
use instructionsimplify instead of a weak clone of ad-hoc folding stuff.
...
llvm-svn: 86616
2009-11-09 23:00:14 +00:00
Chris Lattner
2978ca7b79
stub out a new form of BasicBlock::RemovePredecessorAndSimplify which
...
simplifies instruction users of PHIs when the phi is eliminated. This
will be moved to transforms/utils after some other refactoring.
llvm-svn: 86603
2009-11-09 22:32:36 +00:00
Chris Lattner
ea465e221e
comment typos pointed out by Duncan
...
llvm-svn: 86497
2009-11-09 00:41:49 +00:00
Chris Lattner
5ff7f5672e
reapply 86289, 86278, 86270, 86267, 86266 & 86264 plus a fix
...
(making pred factoring only happen if threading is guaranteed
to be successful).
This now survives an X86-64 bootstrap of llvm-gcc.
llvm-svn: 86355
2009-11-07 08:05:03 +00:00
Devang Patel
3a42e7ac65
Revert following patches to fix llvmgcc bootstrap.
...
86289, 86278, 86270, 86267, 86266 & 86264
Chris, please take a look.
llvm-svn: 86321
2009-11-07 01:32:59 +00:00
Jeffrey Yasskin
8f77e948e5
Avoid "ambiguous 'else'" warning from gcc.
...
llvm-svn: 86314
2009-11-07 00:26:47 +00:00
Chris Lattner
eb690feaef
Fix a bug where we'd call SplitBlockPredecessors with a pred in the
...
set only once even if it has multiple edges to BB.
llvm-svn: 86299
2009-11-06 23:19:58 +00:00
Eli Friedman
a70917b2f4
Remove function left over from other jump threading cleanup.
...
llvm-svn: 86289
2009-11-06 21:24:57 +00:00
Chris Lattner
a8b9ce3f07
Fix a problem discovered on self host.
...
llvm-svn: 86278
2009-11-06 19:21:48 +00:00
Chris Lattner
d91a7960bf
remove more code subsumed by r86264
...
llvm-svn: 86270
2009-11-06 18:24:32 +00:00
Chris Lattner
899ef22acb
eliminate some more code subsumed by r86264
...
llvm-svn: 86267
2009-11-06 18:22:54 +00:00
Chris Lattner
2f6184f6aa
remove now redundant code, r86264 handles this case.
...
llvm-svn: 86266
2009-11-06 18:20:58 +00:00
Chris Lattner
68d2417e05
Extend jump threading to support much more general threading
...
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.
llvm-svn: 86264
2009-11-06 18:15:14 +00:00
Chris Lattner
46b5c642b9
remove a bunch of extraneous LLVMContext arguments
...
from various APIs, addressing PR5325.
llvm-svn: 86231
2009-11-06 04:27:31 +00:00
Chris Lattner
a09062758b
improve DSE when TargetData is not around, based on work by
...
Hans Wennborg!
llvm-svn: 86067
2009-11-04 23:20:12 +00:00
Chris Lattner
85c85c5e04
when folding duplicate conditions, delete the
...
now-probably-dead instruction tree feeding it.
llvm-svn: 83778
2009-10-11 18:39:58 +00:00
Chris Lattner
97b1405207
implement a transformation in jump threading that is currently
...
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.
llvm-svn: 83759
2009-10-11 07:24:57 +00:00
Chris Lattner
6ce85e85f5
restructure some code, no functionality change.
...
llvm-svn: 83756
2009-10-11 04:40:21 +00:00
Chris Lattner
f466bc84c9
factor some code better and move a function, no functionality change.
...
llvm-svn: 83755
2009-10-11 04:33:43 +00:00
Chris Lattner
f99a74e24b
make jump threading on a phi with undef inputs happen.
...
llvm-svn: 83754
2009-10-11 04:18:15 +00:00
Chris Lattner
84095071ea
Change jump threading to use the new SSAUpdater class instead of
...
DemoteRegToStack. This makes it more efficient (because it isn't
creating a ton of load/stores that are eventually removed by a later
mem2reg), and more slightly more effective (because those load/stores
don't get in the way of threading).
llvm-svn: 83706
2009-10-10 09:05:58 +00:00
Nick Lewycky
42fb7452df
Instruction::clone does not need to take an LLVMContext&. Remove that and
...
update all the callers.
llvm-svn: 82889
2009-09-27 07:38:41 +00:00
Chris Lattner
2dd09dbdf7
eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861
...
llvm-svn: 80766
2009-09-02 06:11:42 +00:00
Owen Anderson
55f1c09e31
Push LLVMContexts through the IntegerType APIs.
...
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Owen Anderson
23a204d91b
Move getTrue() and getFalse() to 2.5-like APIs.
...
llvm-svn: 77685
2009-07-31 17:39:07 +00:00
Owen Anderson
b292b8ce70
Move more code back to 2.5 APIs.
...
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Owen Anderson
487375e9a2
Move ConstantExpr to 2.5 API.
...
llvm-svn: 77494
2009-07-29 18:55:55 +00:00
Daniel Dunbar
6115b39ffd
Remove Value::getName{Start,End}, the last of the old Name APIs.
...
llvm-svn: 77152
2009-07-26 09:48:23 +00:00
Daniel Dunbar
9813b0b025
Eliminate some uses of DOUT, cerr, and getNameStart().
...
llvm-svn: 77145
2009-07-26 07:49:05 +00:00
Owen Anderson
edb4a70325
Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
...
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Dan Gohman
67243a4bec
Convert several more passes to use getAnalysisIfAvailable<TargetData>()
...
instead of getAnalysis<TargetData>().
llvm-svn: 76982
2009-07-24 18:13:53 +00:00
Owen Anderson
47db941fd3
Get rid of the Pass+Context magic.
...
llvm-svn: 76702
2009-07-22 00:24:57 +00:00
Owen Anderson
c37bc69e91
Rename getConstantInt{True|False} to get{True|False} at Chris' behest.
...
llvm-svn: 76598
2009-07-21 18:03:38 +00:00
Owen Anderson
4fdeba9706
Revert yesterday's change by removing the LLVMContext parameter to AllocaInst and MallocInst.
...
llvm-svn: 75863
2009-07-15 23:53:25 +00:00
Owen Anderson
b6b2530000
Move EVER MORE stuff over to LLVMContext.
...
llvm-svn: 75703
2009-07-14 23:09:55 +00:00
Owen Anderson
1e5f00e7a7
This started as a small change, I swear. Unfortunately, lots of things call the [I|F]CmpInst constructors. Who knew!?
...
llvm-svn: 75200
2009-07-09 23:48:35 +00:00
Owen Anderson
38264b1554
"LLVMContext* " --> "LLVMContext *"
...
llvm-svn: 74878
2009-07-06 23:00:19 +00:00
Owen Anderson
39f00cc1d4
Thread LLVMContext through the constant folding APIs, which touches a lot of files.
...
llvm-svn: 74844
2009-07-06 18:42:36 +00:00