Chris Lattner
a97922837e
change GetStoreValueForLoad to use IRBuilder, which is cleaner and
...
implicitly constant folds.
llvm-svn: 90977
2009-12-09 18:13:28 +00:00
Bob Wilson
9e68616e49
Fix a comment.
...
llvm-svn: 90975
2009-12-09 18:05:27 +00:00
Chris Lattner
db0baa713d
change AnalyzeLoadFromClobberingMemInst/AnalyzeLoadFromClobberingStore
...
to require the load ty/ptr to be passed in, no functionality change.
llvm-svn: 90960
2009-12-09 07:37:07 +00:00
Chris Lattner
b3587059c8
change AnalyzeLoadFromClobberingWrite and clients to pass in type
...
and pointer instead of the load. No functionality change.
llvm-svn: 90959
2009-12-09 07:34:10 +00:00
Chris Lattner
e0207b46d2
change NonLocalDepEntry from being a typedef for an std::pair to be its
...
own small class. No functionality change.
llvm-svn: 90956
2009-12-09 07:08:01 +00:00
Chris Lattner
4645bb977a
add some aborts to #if 0's.
...
llvm-svn: 90929
2009-12-09 02:41:54 +00:00
Chris Lattner
dda5ca59e2
Switch GVN and memdep to use PHITransAddr, which correctly handles
...
phi translation of complex expressions like &A[i+1]. This has the
following benefits:
1. The phi translation logic is all contained in its own class with
a strong interface and verification that it is self consistent.
2. The logic is more correct than before. Previously, if intermediate
expressions got PHI translated, we'd miss the update and scan for
the wrong pointers in predecessor blocks. @phi_trans2 is a testcase
for this.
3. We have a lot less code in memdep.
We can handle phi translation across blocks of things like @phi_trans3,
which is pretty insane :).
This patch should fix the miscompiles of 255.vortex, and I tested it
with a bootstrap of llvm-gcc, llvm-test and dejagnu of course.
llvm-svn: 90926
2009-12-09 01:59:31 +00:00
Bob Wilson
04cc375a1a
Some superficial cleanups.
...
llvm-svn: 90866
2009-12-08 18:27:03 +00:00
Bob Wilson
d673b32280
Clean up dead operands left around after SROA replaces a mem intrinsic.
...
I'm not aware that this does anything significant on its own, but it's
needed for another patch that I'm working on.
llvm-svn: 90864
2009-12-08 18:22:03 +00:00
Nick Lewycky
5a00cea348
Remove unnecessary #include "llvm/LLVMContext.h".
...
llvm-svn: 90836
2009-12-08 05:45:41 +00:00
Chris Lattner
7066a138ff
fix PR5698
...
llvm-svn: 90708
2009-12-06 17:17:23 +00:00
Chris Lattner
ea3007ddb8
constant fold loads from memcpy's from global constants. This is important
...
because clang lowers nontrivial automatic struct/array inits to memcpy from
a global array.
llvm-svn: 90698
2009-12-06 05:29:56 +00:00
Chris Lattner
8885e71303
add support for forwarding mem intrinsic values to non-local loads.
...
llvm-svn: 90697
2009-12-06 04:54:31 +00:00
Chris Lattner
5eba6ee969
Handle forwarding local memsets to loads. For example, we optimize this:
...
short x(short *A) {
memset(A, 1, sizeof(*A)*100);
return A[42];
}
to 'return 257' instead of doing the load.
llvm-svn: 90695
2009-12-06 01:57:02 +00:00
Nick Lewycky
10693e2bb0
Generalize this optimization to work on equality comparisons between any two
...
integers that are constant except for a single bit (the same n-th bit in each).
llvm-svn: 90646
2009-12-05 05:00:00 +00:00
Bob Wilson
8c1617ed73
Fix up some comments.
...
llvm-svn: 90603
2009-12-04 21:57:37 +00:00
Bob Wilson
514e0d319a
Fix 80-column violations.
...
llvm-svn: 90601
2009-12-04 21:51:35 +00:00
Bob Wilson
c717c5e7ae
Fix a comment typo.
...
llvm-svn: 90487
2009-12-03 21:47:07 +00:00
Owen Anderson
251cb28a25
Fix this crasher, and add a FIXME for a missed optimization.
...
llvm-svn: 90408
2009-12-03 03:43:29 +00:00
Chris Lattner
9ce833945e
improve portability to avoid conflicting with std::next in c++'0x.
...
Patch by Howard Hinnant!
llvm-svn: 90365
2009-12-03 00:50:42 +00:00
Owen Anderson
f47cde694f
Cleanup/remove some parts of the lifetime region handling code in memdep and GVN,
...
per Chris' comments. Adjust testcases to match.
llvm-svn: 90304
2009-12-02 07:35:19 +00:00
Chris Lattner
b541c63e60
factor some code better.
...
llvm-svn: 90299
2009-12-02 06:44:58 +00:00
Chris Lattner
90aff65316
formatting cleanups.
...
llvm-svn: 90298
2009-12-02 06:35:55 +00:00
Chris Lattner
cb2c4e9f42
tidy up, remove dependence on order of evaluation of function args from EmitMemCpy.
...
llvm-svn: 90297
2009-12-02 06:05:42 +00:00
Chris Lattner
7c0c90df97
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
Benjamin Kramer
d9780ec7c5
Revert r90089 for now, it's breaking selfhost.
...
llvm-svn: 90097
2009-11-29 21:17:48 +00:00
Benjamin Kramer
a1d24b5a8d
Fix two FIXMEs.
...
llvm-svn: 90089
2009-11-29 20:29:30 +00:00
Chris Lattner
cd6fed25d5
add testcases for the foo_with_overflow op xforms added recently and
...
fix bugs exposed by the tests. Testcases from Alastair Lynn!
llvm-svn: 90056
2009-11-29 02:57:29 +00:00
Chris Lattner
d48ff7ea6a
Implement PR5634.
...
llvm-svn: 90046
2009-11-29 00:51:17 +00:00
Chris Lattner
83284453a1
reenable load address insertion in load pre. This allows us to
...
handle cases like this:
void test(int N, double* G) {
long j;
for (j = 1; j < N - 1; j++)
G[j+1] = G[j] + G[j+1];
}
where G[1] isn't live into the loop.
llvm-svn: 90041
2009-11-28 16:08:18 +00:00
Chris Lattner
f8d8142a06
Enhance InsertPHITranslatedPointer to be able to return a list of newly
...
inserted instructions. No functionality change until someone starts using it.
llvm-svn: 90039
2009-11-28 15:39:14 +00:00
Chris Lattner
f3e5cbfc99
disable value insertion for now, I need to figure out how
...
to inform GVN about the newly inserted values. This fixes
PR5631.
llvm-svn: 90022
2009-11-27 22:50:07 +00:00
Chris Lattner
73b425ba51
Rework InsertPHITranslatedPointer to handle the recursive case, this
...
fixes PR5630 and sets the stage for the next phase of goodness (testcase
pending).
llvm-svn: 90019
2009-11-27 22:05:15 +00:00
Chris Lattner
bdaed088ea
factor some logic out of instcombine into a new SimplifyAddInst method.
...
llvm-svn: 90011
2009-11-27 17:42:22 +00:00
Chris Lattner
cdfa9dadf1
fix PR5436 by making the 'simple' case of SRoA not promote out of range
...
array indexes. The "complex" case of SRoA still handles them, and correctly.
This fixes a weirdness where we'd correctly avoid transforming A[0][42] if
the 42 was too large, but we'd only do it if it was one gep, not two separate
ones.
llvm-svn: 90007
2009-11-27 16:37:41 +00:00
Chris Lattner
a466dbe80a
teach GVN's load PRE to insert computations of the address in predecessors
...
where it is not available. It's unclear how to get this inserted
computation into GVN's scalar availability sets, Owen, help? :)
llvm-svn: 89997
2009-11-27 08:25:10 +00:00
Chris Lattner
0971e6da1f
Fix phi translation in load PRE to agree with the phi
...
translation done by memdep, and reenable gep translation
again.
llvm-svn: 89992
2009-11-27 06:31:14 +00:00
Chris Lattner
6611a6f733
factor some instcombine simplifications for getelementptr out to a new
...
SimplifyGEPInst method in InstructionSimplify.h. No functionality change.
llvm-svn: 89980
2009-11-27 00:29:05 +00:00
Chris Lattner
e949f49b23
fix crash on Transforms/InstCombine/intrinsics.ll introduced by r89970
...
llvm-svn: 89972
2009-11-26 22:08:06 +00:00
Chris Lattner
cf7665b0c8
Fix PR5471 by removing an instcombine xform. Some pieces of the code
...
generates store to undef and some generates store to null as the idiom
for undefined behavior. Since simplifycfg zaps both, don't remove the
undefined behavior in instcombine.
llvm-svn: 89971
2009-11-26 22:04:42 +00:00
Chris Lattner
08e20f453d
implement a bunch of xforms for overflow intrinsics, based on a patch
...
by Alastair Lynn.
llvm-svn: 89970
2009-11-26 21:42:47 +00:00
Edward O'Callaghan
4b197b8908
Reverting patch in revision 89758, initial attempt at fixing PR5373 has proven to be bogus.
...
llvm-svn: 89844
2009-11-25 05:38:41 +00:00
Edward O'Callaghan
8c1cd4fdbc
Fix for PR5373, Credit to Jakub Staszak.
...
llvm-svn: 89758
2009-11-24 11:51:52 +00:00
Dan Gohman
0ef3e7cf76
Fix a use of an invalidated iterator in the case where there are multiple
...
adjacent uses of a dead basic block from the same user. This fixes PR5596.
llvm-svn: 89658
2009-11-23 16:13:39 +00:00
Nick Lewycky
b3bedf4b2d
Pull LLVMContext out of PromoteMemToReg.
...
llvm-svn: 89645
2009-11-23 03:50:44 +00:00
Nick Lewycky
76fbcdaaa7
Remove LLVMContext and its include.
...
llvm-svn: 89644
2009-11-23 03:34:29 +00:00
Nick Lewycky
9d1ee635e3
Reapply r88830 with a bugfix: this transform only applies to icmp eq/ne. This
...
fixes part of PR5438.
llvm-svn: 89639
2009-11-23 03:17:33 +00:00
Eric Christopher
455f4d8400
Add more optimizations for object size checking, enable handling of
...
object size intrinsic and verify return type is correct. Collect various
code in one place.
llvm-svn: 89523
2009-11-21 01:01:30 +00:00
Dan Gohman
94cca19d9d
Fix IPSCCP's code for deleting dead blocks to tolerate outstanding
...
blockaddress users. This fixes PR5569.
llvm-svn: 89483
2009-11-20 20:19:14 +00:00
Daniel Dunbar
09a7f92b02
Revert "Add some rough optimizations for checking routines.", it buildeth not.
...
llvm-svn: 89482
2009-11-20 20:17:30 +00:00
Eric Christopher
61485dfd00
Add some rough optimizations for checking routines.
...
llvm-svn: 89479
2009-11-20 19:57:37 +00:00
Duncan Sands
5f5ec2a6ec
Fix PR5563, an expensive checks failure when running on
...
tests/Transforms/InstCombine/shufflemask-undef.ll. If
anyone cares, the use of 2*e here (and the equivalent
all over the place in instcombine) seems wrong, though
harmless: it should really be twice the length of the
input vector. I think shufflevector used to require
that the mask have the same length as the input, but I
don't think that's true any more. I don't care enough
about vectors to do anything about this...
llvm-svn: 89456
2009-11-20 13:19:51 +00:00
Dan Gohman
026230b0a9
Enable hoisting of loads from constant memory by default. In cases where
...
they are lowered to instruction sequences more complex than a simple
load, such that CodeGen cannot rematerialize them, a reload from a
spill slot is likely to be cheaper than the complex sequence.
llvm-svn: 89374
2009-11-19 19:00:10 +00:00
Jim Grosbach
2853c74dc9
grammar
...
llvm-svn: 89145
2009-11-17 21:37:04 +00:00
Jim Grosbach
1aa8f6c5c7
80-column violations
...
llvm-svn: 89123
2009-11-17 19:05:35 +00:00
Evan Cheng
aaa58b7653
Generalize OptimizeLoopTermCond to optimize more loop terminating icmp to use postinc iv.
...
llvm-svn: 89116
2009-11-17 18:10:11 +00:00
Jim Grosbach
5851dbf184
Remove trailing whitespace
...
llvm-svn: 89110
2009-11-17 17:53:56 +00:00
David Greene
47e8728c22
Fix an expensive-checks error.
...
The Mask and LHSMask may not be of the same size, so don't do the
transformation if they're different.
llvm-svn: 88972
2009-11-16 21:52:23 +00:00
Duncan Sands
03e15012ed
CreateIntCast takes an "isSigned" parameter. Pass "true" for it, rather than
...
a name.
llvm-svn: 88908
2009-11-16 12:32:28 +00:00
Chris Lattner
15cd19dddb
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
59f69de88f
fix a bug handling 'not x' when x is undef.
...
llvm-svn: 88864
2009-11-15 19:57:43 +00:00
Nick Lewycky
f05946faff
Revert r88830 and r88831 which appear to have caused a selfhost buildbot some
...
grief. I suspect this patch merely exposed a bug else.
llvm-svn: 88841
2009-11-15 07:47:32 +00:00
Nick Lewycky
14a2122db3
Teach instcombine to look for booleans in wider integers when it encounters a
...
zext(icmp). It may be able to optimize that away. This fixes one of the cases
in PR5438.
llvm-svn: 88830
2009-11-15 05:55:17 +00:00
Nick Lewycky
316e082216
Remove LLVMContext from reassociate. It was threaded through every function but
...
ultimately never used.
llvm-svn: 88763
2009-11-14 07:25:54 +00:00
Dan Gohman
406baaac43
Add an option for running GVN with redundant load processing disabled.
...
llvm-svn: 88742
2009-11-14 02:27:51 +00:00
Owen Anderson
81f2ff1d61
Re-enable this code, since redundant PHIs are now being better nuked.
...
llvm-svn: 87042
2009-11-12 23:22:41 +00:00
Evan Cheng
b0a193db31
- Teach LSR to avoid changing cmp iv stride if it will create an immediate that
...
cannot be folded into target cmp instruction.
- Avoid a phase ordering issue where early cmp optimization would prevent the
later count-to-zero optimization.
- Add missing checks which could cause LSR to reuse stride that does not have
users.
- Fix a bug in count-to-zero optimization code which failed to find the pre-inc
iv's phi node.
- Remove, tighten, loosen some incorrect checks disable valid transformations.
- Quite a bit of code clean up.
llvm-svn: 86969
2009-11-12 07:35:05 +00:00
Chris Lattner
01fddcec53
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
3e63fb7318
various fixes to the lattice transfer functions.
...
llvm-svn: 86952
2009-11-12 04:57:13 +00:00
Chris Lattner
c1619b4fe9
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
68f3b53ddc
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
ea8b237a74
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
b5bb115ece
expose edge information and switch j-t to use it.
...
llvm-svn: 86920
2009-11-12 01:29:10 +00:00
Chris Lattner
73b7ed2d9c
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
36009e416c
remove the now dead condprop pass, PR3906.
...
llvm-svn: 86810
2009-11-11 05:56:35 +00:00
Chris Lattner
b45381c3f0
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
c1709a798a
add a fixme
...
llvm-svn: 86766
2009-11-11 00:21:58 +00:00
Evan Cheng
ea76ec6720
Block terminator may be a switch.
...
llvm-svn: 86761
2009-11-11 00:00:21 +00:00
Chris Lattner
f66a81aecd
implement a TODO by teaching jump threading about "xor x, 1".
...
llvm-svn: 86739
2009-11-10 22:39:16 +00:00
Chris Lattner
ec4264fbb0
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
a163be92fc
fix a crash in SCCP handling extractvalue of an array, pointed out and
...
tracked down by Stephan Reiter!
llvm-svn: 86726
2009-11-10 22:02:09 +00:00
Chris Lattner
f48b199c43
improve comment.
...
llvm-svn: 86723
2009-11-10 21:45:09 +00:00
Chris Lattner
fca84b3dff
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
Evan Cheng
f5e85bec73
Generalize lsr code that optimize loop to count down towards zero.
...
llvm-svn: 86715
2009-11-10 21:14:05 +00:00
Duncan Sands
1053bb18c6
Add defensive break.
...
llvm-svn: 86705
2009-11-10 19:36:40 +00:00
Duncan Sands
bfba3451b2
Fix obvious typo.
...
llvm-svn: 86694
2009-11-10 18:21:37 +00:00
Chris Lattner
dc0722e39a
clarify logic.
...
llvm-svn: 86689
2009-11-10 17:00:47 +00:00
Duncan Sands
732a2ed037
Teach DSE to eliminate useless trampolines.
...
llvm-svn: 86683
2009-11-10 13:49:50 +00:00
Duncan Sands
a25c87ef1f
Add brackets to make gcc-4.4 happy.
...
llvm-svn: 86681
2009-11-10 09:32:10 +00:00
Chris Lattner
562cc40dbb
unify the code that determines whether it is a good idea to change the type
...
of a computation. This fixes some infinite loops when dealing with TD that
has no native types.
llvm-svn: 86670
2009-11-10 07:23:37 +00:00
Nick Lewycky
4939d449e1
Simplify.
...
llvm-svn: 86668
2009-11-10 07:00:43 +00:00
Nick Lewycky
f6be02e523
Reapply r86359, "Teach dead store elimination that certain intrinsics write to
...
memory just like a store" with bug fixed (partial-overwrite.ll is the
regression test).
llvm-svn: 86667
2009-11-10 06:46:40 +00:00
Chris Lattner
f3fc70a936
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
a087a1ca04
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
a279728372
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
Jeffrey Yasskin
23ac706aab
Fix DenseMap iterator constness.
...
This patch forbids implicit conversion of DenseMap::const_iterator to
DenseMap::iterator which was possible because DenseMapIterator inherited
(publicly) from DenseMapConstIterator. Conversion the other way around is now
allowed as one may expect.
The template DenseMapConstIterator is removed and the template parameter
IsConst which specifies whether the iterator is constant is added to
DenseMapIterator.
Actually IsConst parameter is not necessary since the constness can be
determined from KeyT but this is not relevant to the fix and can be addressed
later.
Patch by Victor Zverovich!
llvm-svn: 86636
2009-11-10 01:02:17 +00:00
Chris Lattner
3730cf6fef
factor simplification logic for AND and OR out to InstSimplify from instcombine.
...
llvm-svn: 86635
2009-11-10 00:55:12 +00:00
Chris Lattner
9941f27797
pull a bunch of logic out of instcombine into instsimplify for compare
...
simplification, this handles the foldable fcmp x,x cases among many others.
llvm-svn: 86627
2009-11-09 23:55:12 +00:00
Chris Lattner
9aa69f2205
inline a simple function.
...
llvm-svn: 86625
2009-11-09 23:31:49 +00:00
Chris Lattner
25700676d4
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