Commit Graph

6451 Commits

Author SHA1 Message Date
Chris Lattner
8d10f9d4a8 teach ComputeNumSignBits to look through PHI nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92964 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 23:44:37 +00:00
Chris Lattner
075f692939 Enhance instcombine to reason more strongly about promoting computation
that feeds into a zext, similar to the patch I did yesterday for sext.
There is a lot of room for extension beyond this patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92962 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 23:41:00 +00:00
Benjamin Kramer
66b581ef49 Use a do-while loop instead of while + boolean.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92912 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 13:50:07 +00:00
Duncan Sands
5d8ea117a0 Be less stingy as to how many selects and phi nodes we
are prepared to look through.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92898 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 05:48:42 +00:00
Chris Lattner
4039bd0550 handle ConstantVector while I'm in here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92892 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 01:20:20 +00:00
Chris Lattner
a0e9a2475c fix a globalopt crash on 'bullet' (handling evaluation of a store
to an element of a vector in a static ctor) which occurs with an 
unrelated patch I'm testing.  Annoyingly, EvaluateStoreInto basically 
does exactly the same stuff as InsertElement constant folding, but it
now handles vectors, and you can't insertelement into a vector.  It
would be 'really nice' if GEP into a vector were not legal.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92889 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 01:16:21 +00:00
Eric Christopher
130063207d Move the object size intrinsic optimization to inst-combine and make
it work for any integer size return type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92853 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 20:04:44 +00:00
Duncan Sands
e10920d678 Fix a README item: have functionattrs look through selects and
phi nodes when deciding which pointers point to local memory.
I actually checked long ago how useful this is, and it isn't
very: it hardly ever fires in the testsuite, but since Chris
wants it here it is!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 15:37:47 +00:00
Mikhail Glushenkov
0ecbdeb14f Formatting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92831 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 09:20:39 +00:00
Duncan Sands
7c422ac216 Partially address a README by having functionattrs consider calls to
memcpy, memset and other intrinsics that only access their arguments
to be readnone if the intrinsic's arguments all point to local memory.
This improves the testcase in the README to readonly, but it could in
theory be made readnone, however this would involve more sophisticated
analysis that looks through the memcpy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92829 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 08:45:52 +00:00
Chris Lattner
5c24a6da29 tweaks suggested by Duncan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92824 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 05:32:15 +00:00
Chris Lattner
e0e4cc7fd5 Teach instcombine's sext elimination logic to be more aggressive.
Previously, instcombine would only promote an expression tree to
the larger type if doing so eliminated two casts.  This is because
a need to manually do the sign extend after the promoted expression
tree with two shifts.  Now, we keep track of whether the result of
the computation is going to be properly sign extended already.  If
so, we can unconditionally promote the expression, which allows us
to zap more sext's.

This implements rdar://6598839 (aka gcc pr38751)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92815 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 01:56:21 +00:00
Chris Lattner
68c6e8998b simplify this code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:00:30 +00:00
Chris Lattner
94aab49339 make this a static function instead of a method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 22:30:42 +00:00
Chris Lattner
7a34d6c450 more rearrangement and cleanup, fix my test failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92792 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 22:21:18 +00:00
Chris Lattner
274ad68cc7 cleanup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92790 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 22:07:33 +00:00
Chris Lattner
c0f79af143 remove two trunc xforms that are subsumed by EvaluateInDifferentType.
The only difference is that EvaluateInDifferentType checks to ensure
they are profitable before doing them :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92788 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 22:01:41 +00:00
Chris Lattner
464dc81803 just remove this xform which is subsumed by others.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92775 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 21:16:30 +00:00
Chris Lattner
49bdfefc8d move a trunc-specific transform out of commonIntCastTransforms into visitTrunc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92773 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 21:11:17 +00:00
Benjamin Kramer
8c65f6e71c Move remaining stuff to the isInteger predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92771 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 21:05:54 +00:00
Chris Lattner
718bf3f89d move a zext specific xform out of commonIntCastTransforms into visitZExt and modernize it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92770 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 21:04:47 +00:00
Chris Lattner
f86d799a29 move a trunc-specific xform out of commonIntCastTransforms into visitTrunc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92768 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 20:57:30 +00:00
Chris Lattner
3168c7dd25 reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92766 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 20:56:24 +00:00
Benjamin Kramer
11acaa374c Convert a ton of simple integer type equality tests to the new predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 20:07:06 +00:00
Chris Lattner
033574074d optimize comparisons against cttz/ctlz/ctpop, patch by Alastair Lynn!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92745 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 18:09:56 +00:00
Dan Gohman
ba25f0924e Nick Lewycky pointed out that this code makes changes unconditionally.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92739 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 17:50:58 +00:00
Dan Gohman
9fff2187a2 Set Changed properly after calling DeleteDeadPHIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92735 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 16:31:45 +00:00
Dan Gohman
321a813c53 Use do+while instead of while for loops which obviously have a
non-zero trip count. Use SmallVector's pop_back_val().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92734 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 16:27:25 +00:00
Dan Gohman
b7a9f2b504 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92733 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 16:20:55 +00:00
Dan Gohman
90fe0bd68c Make RecursivelyDeleteTriviallyDeadInstructions,
RecursivelyDeleteDeadPHINode, and DeleteDeadPHIs return a flag
indicating whether they made any changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92732 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 15:45:31 +00:00
Benjamin Kramer
eade002094 Add newline at EOF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92727 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 13:32:48 +00:00
Benjamin Kramer
f012705c7e Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92726 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 13:12:22 +00:00
Chris Lattner
804272c8d6 prune some #includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92712 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:54:43 +00:00
Chris Lattner
25f2a23b4a split and/or/xor out into one overly-large (2000LOC) file. However, I think
it does make sense to keep them together, at least for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92711 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:50:36 +00:00
Chris Lattner
d3c5b2d322 missed file with previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92710 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:45:02 +00:00
Chris Lattner
9cdd5f3fe3 split instcombine of shifts out to its own file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:44:46 +00:00
Chris Lattner
948cdeba97 eliminate getBitCastOperand and simplify some over-complex inbounds stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92708 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:42:10 +00:00
Chris Lattner
753a2b464d split call handling out to InstCombineCalls.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92707 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:32:13 +00:00
Chris Lattner
16507fe9fd optimize cttz and ctlz when we can prove something about the
leading/trailing bits.  Patch by Alastair Lynn!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92706 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:23:56 +00:00
Chris Lattner
f87cd93e0c this inline function moved to addsub
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92705 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:20:54 +00:00
Chris Lattner
53a19b73b5 split add/sub out to its own file. Eliminate use of
dyn_castNotVal in the X+~X transform.  dyn_castNotVal is
dramatic overkill for what the xform needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92704 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:18:46 +00:00
Chris Lattner
248a84beb3 all the places we use hasOneUse() we know are instructions, so inline
and simplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92700 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:04:23 +00:00
Chris Lattner
dea34da6f8 eliminate AssociativeOpt and its last uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92697 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 07:01:16 +00:00
Chris Lattner
a317e044fb inline the FoldICmpLogical functor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92695 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:59:49 +00:00
Chris Lattner
32c0cf5af9 inline the 'AddRHS' transformation, simplifying things significantly.
Eliminate the 'AddMaskingAnd' transformation, it is redundant with this
more general code right below it:
  // A+B --> A|B iff A and B have no bits set in common.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92693 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:29:13 +00:00
Chris Lattner
d0db8e8bad remove massive over-genality manifested as a big template
that got instantiated.  There is no reason for instcombine
to try this hard for simple associative optimizations.  Next
up, eliminate the template completely.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92692 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:24:06 +00:00
Chris Lattner
d12c27ce00 split mul/div/rem instructions out to their own file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92689 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:09:35 +00:00
Chris Lattner
1c22c80d71 clean up header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92688 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:05:07 +00:00
Chris Lattner
c6334b97e1 split select out to its own file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92687 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:03:12 +00:00
Chris Lattner
8d9b8d717e split out load/store/alloca.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92685 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 05:57:49 +00:00
Chris Lattner
d5da271863 reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92684 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 05:42:08 +00:00
Chris Lattner
b8a5cecd6b split vector stuff out to InstCombineVectorOps.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92683 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 05:36:20 +00:00
Chris Lattner
f54e729629 split PHI node stuff out to InstCombinePHI.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92682 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 05:31:55 +00:00
Chris Lattner
43fd9017a6 convert various IntrinsicInst's to use class instead of struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92681 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 05:21:26 +00:00
Chris Lattner
5f94af0f72 fix an infinite loop in reassociate building emacs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92679 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 04:55:35 +00:00
David Greene
5ededf7d42 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92639 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:28:37 +00:00
David Greene
3307e95188 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92636 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:28:29 +00:00
David Greene
3a078b5208 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92633 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:28:12 +00:00
David Greene
fd2ab9ff44 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92631 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:28:07 +00:00
David Greene
3215b0ee82 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92629 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:28:05 +00:00
David Greene
09d70db3ed Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92627 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:54 +00:00
David Greene
c0aa67950a Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92625 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:51 +00:00
David Greene
cb33fd17cc Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92624 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:47 +00:00
David Greene
d241e38d26 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92623 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:44 +00:00
David Greene
163fb1f93e Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92622 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:39 +00:00
David Greene
7439239fca Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92620 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:33 +00:00
David Greene
f15826999b Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92619 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:30 +00:00
David Greene
a1fa76cb54 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92617 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:24 +00:00
David Greene
6a6b90ebd9 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92615 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:21 +00:00
David Greene
fe7fe6603f Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92614 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:19 +00:00
David Greene
bf7f78e625 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92613 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:17 +00:00
David Greene
971cc7e883 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92612 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:15 +00:00
David Greene
68d67fdf20 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92611 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:11 +00:00
David Greene
504c7d8973 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92610 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:09 +00:00
David Greene
f67ef318aa Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92609 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:06 +00:00
David Greene
d4c56fbc39 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92608 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:04 +00:00
David Greene
0b9afb41c4 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92607 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:01 +00:00
David Greene
fae7706dfd Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92606 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:57 +00:00
David Greene
1216e6bf9d Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92605 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:54 +00:00
David Greene
89d6fd36a2 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92604 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:52 +00:00
David Greene
1af40cacd4 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92603 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:49 +00:00
David Greene
0f4c988a27 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92602 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:45 +00:00
David Greene
ddc5de4cd6 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92601 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:44 +00:00
David Greene
a9ad9c24ae Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92600 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:41 +00:00
David Greene
83964b7944 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92599 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:26:39 +00:00
Devang Patel
44a29e066a Remove dead debug info intrinsics.
Intrinsic::dbg_stoppoint
 Intrinsic::dbg_region_start 
 Intrinsic::dbg_region_end 
 Intrinsic::dbg_func_start
AutoUpgrade simply ignores these intrinsics now.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92557 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:10:40 +00:00
Daniel Dunbar
da92fb430e Fix some struct/class specifier mismatches.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92550 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 00:15:58 +00:00
Chris Lattner
d7f5a58890 Truncate GEP indexes larger than the pointer size down to pointer size
when doing this transform if the GEP is not inbounds.  No testcase because
it is very difficult to trigger this: instcombine already canonicalizes
GEP indices to pointer size, so it relies specific permutations of the
instcombine worklist.

Thanks to Duncan for pointing this possible problem out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92495 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 18:57:15 +00:00
Chris Lattner
0cb1e9edd5 silence a bogus 'might be used uninit' warning from GCC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92494 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 18:48:26 +00:00
Chris Lattner
f3d1b5dd68 move some more cast-related stuff
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92471 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:59:07 +00:00
Mikhail Glushenkov
ed5cb593ef 80-col violations, trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92470 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:55:25 +00:00
Chris Lattner
5f0290e0ef move the [Can]EvaluateInDifferentType functions out to InstCombineCasts.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92469 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:54:59 +00:00
Chris Lattner
80f43d339f split 943 lines of instcombine out to a new InstCombineCasts.cpp
file.  InstructionCombining.cpp is now down to a svelte 9300 lines :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92468 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:53:58 +00:00
Chris Lattner
02446fc99a split instcombine of compares (visit[FI]Cmp) out to
a new InstCombineCompares.cpp file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92467 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:37:31 +00:00
Chris Lattner
a766e19705 update cmakefile
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92466 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:19:55 +00:00
Chris Lattner
e0b4b721aa move the 'SimplifyDemandedFoo' methods out to their own file, cutting 1K lines out of instcombine.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92465 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:17:19 +00:00
Chris Lattner
ac8f2fd2e2 split the instcombine class definition out to a header shared
among the instcombine library.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92463 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:12:23 +00:00
Chris Lattner
4de84762bd remove a ton of unneeded LLVMContext stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92462 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 07:02:48 +00:00
Chris Lattner
3df5c6fff1 move InstCombineWorklist out to its own header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92461 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 06:30:00 +00:00
Chris Lattner
ce6daa4c58 forgot to svn add these.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92460 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 06:28:20 +00:00
Chris Lattner
dffbef0d76 move instcombine to its own library, it's past time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92459 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 06:23:24 +00:00
Chris Lattner
e4412c1f0b implement an instcombine xform needed by clang's codegen
on the example in PR4216.  This doesn't trigger in the testsuite,
so I'd really appreciate someone scrutinizing the logic for
correctness.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 06:03:59 +00:00
Chris Lattner
a0085af871 pull my debug hooks out, I'm done with this xform for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92446 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-03 06:58:48 +00:00
Nick Lewycky
cccbe7e415 Small cleanups, refactor some duplicated code into a single method. No
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-03 04:39:07 +00:00
Chris Lattner
56ba7a74b9 generalize the previous transformation to handle indexing into
arrays of structs and other arrays, so long as all the subsequent
indexes are constants.  This triggers frequently for stuff like:

@divisions = internal constant [29 x [2 x i32]] [[2 x i32] zeroinitializer, [2 x i32] [i32 0, i32 1], [2 x i32] [i32 0, i32 2], [2 x i32] [i32 0, i32 1], [2 x i32] zeroinitializer, [2 x i32] [i32 0, i32 1], [2 x i32] [i32 0, i32 1], [2 x i32] [i32 0, i32 2], [2 x i32] [i32 0, i32 2], [2 x i32] zeroinitializer, [2 x i32] zeroinitializer, [2 x i32] zeroinitializer, [2 x i32] [i32 0, i32 2], [2 x i32] [i32 0, i32 1], [2 x i32] zeroinitializer, [2 x i32] [i32 1, i32 0], [2 x i32] [i32 1, i32 1], [2 x i32] [i32 1, i32 1], [2 x i32] [i32 1, i32 2], [2 x i32] [i32 1, i32 1], [2 x i32] [i32 1, i32 0], [2 x i32] [i32 1, i32 2], [2 x i32] [i32 1, i32 2], [2 x i32] [i32 1, i32 0], [2 x i32] [i32 1, i32 0], [2 x i32] [i32 1, i32 0], [2 x i32] [i32 1, i32 1], [2 x i32] [i32 1, i32 2], [2 x i32] [i32 1, i32 2]], align 32 ; <[29 x [2 x i32]]*> [#uses=50]

	  %623 = getelementptr inbounds [29 x [2 x i32]]* @divisions, i64 0, i64 %619, i64 0 ; <i32*> [#uses=1]
	   %684 = icmp eq i32 %683, 999 

also for the "my_defs" table in 'gs', etc.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92444 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-03 03:03:27 +00:00
Nick Lewycky
11ed0317bc Cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-03 00:55:31 +00:00
Chris Lattner
df3d63b896 teach instcombine to optimize idioms like A[i]&42 == 0. This
occurs in 403.gcc in mode_mask_array, in safe-ctype.c (which
is copied in multiple apps) in _sch_istable, etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92427 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 22:08:28 +00:00
Chris Lattner
b4f82b4b4f Teach the table lookup optimization to generate range compares
when a consequtive sequence of elements all satisfies the 
predicate.  Like the double compare case, this generates better
code than the magic constant case and generalizes to more than
32/64 element array lookups.

Here are some examples where it triggers.  From 403.gcc, most
accesses to the rtx_class array are handled, e.g.:

@rtx_class = constant [153 x i8] c"xxxxxmmmmmmmmxxxxxxxxxxxxmxxxxxxiiixxxxxxxxxxxxxxxxxxxooxooooooxxoooooox3x2c21c2222ccc122222ccccaaaaaa<<<<<<<<<<<<<<<<<<111111111111bbooxxxxxxxxxxcc2211x", align 32 ; <[153 x i8]*> [#uses=547]
   %142 = icmp eq i8 %141, 105
@rtx_class = constant [153 x i8] c"xxxxxmmmmmmmmxxxxxxxxxxxxmxxxxxxiiixxxxxxxxxxxxxxxxxxxooxooooooxxoooooox3x2c21c2222ccc122222ccccaaaaaa<<<<<<<<<<<<<<<<<<111111111111bbooxxxxxxxxxxcc2211x", align 32 ; <[153 x i8]*> [#uses=543]
	   %165 = icmp eq i8 %164, 60      

Also, most of the 59-element arrays (mode_class/rid_to_yy, etc) 
optimized before are actually range compares.  This lets 32-bit
machines optimize them.

400.perlbmk has stuff like this:

400.perlbmk: PL_regkind, even for 32-bit:
@PL_regkind = constant [62 x i8] c"\00\00\02\02\02\06\06\06\06\09\09\0B\0B\0D\0E\0E\0E\11\12\12\14\14\16\16\18\18\1A\1A\1C\1C\1E\1F !!!$$&'((((,-.///88886789:;8$", align 32 ; <[62 x i8]*> [#uses=4]
	   %811 = icmp ne i8 %810, 33 

@PL_utf8skip = constant [256 x i8] c"\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\04\04\04\04\04\04\04\04\05\05\05\05\06\06\07\0D", align 32 ; <[256 x i8]*> [#uses=94]
	   %12 = icmp ult i8 %10, 2
           
etc.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92426 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 21:50:18 +00:00
Chris Lattner
1c91fae649 theoretically the negate we find could be in a different function, check
for this case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92425 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 21:46:33 +00:00
Chris Lattner
82602bc089 use enums for the over/underdefined markers for clarity. Switch
to using -2/-3 instead of -1/-2 for a future xform.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92423 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 20:20:33 +00:00
Chris Lattner
5fadf17709 remove the random sampling framework, which is not maintained anymore.
If there is interest, it can be resurrected from SVN.  PR4912.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92422 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 20:07:03 +00:00
Nick Lewycky
f994bf00b5 Fix logic error in previous commit. The != case needs to become an or, not an
and.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92419 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 16:14:56 +00:00
Nick Lewycky
546d63176e Optimize pointer comparison into the typesafe form, now that the backends will
handle them efficiently. This is the opposite direction of the transformation
we used to have here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92418 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 15:25:44 +00:00
Chris Lattner
bef37376be Generalize the previous xform to handle cases where exactly
two elements match or don't match with two comparisons.  For
example, the testcase compiles into:

define i1 @test5(i32 %X) {
  %1 = icmp eq i32 %X, 2                          ; <i1> [#uses=1]
  %2 = icmp eq i32 %X, 7                          ; <i1> [#uses=1]
  %R = or i1 %1, %2                               ; <i1> [#uses=1]
  ret i1 %R
}

This generalizes the previous xforms when the array is larger than
64 elements (and this case matches) and generates better code for
cases where it overlaps with the magic bitshift case.

This generalizes more cases than you might expect.  For example,
400.perlbmk has:

@PL_utf8skip = constant [256 x i8] c"\01\01\01\...
%15 = icmp ult i8 %7, 7

403.gcc has:
@rid_to_yy = internal constant [114 x i16] [i16 259, i16 260, ...
%18 = icmp eq i16 %16, 295 

and xalancbmk has a bunch of examples, such as 
_ZN11xercesc_2_5L15gCombiningCharsE and _ZN11xercesc_2_5L10gBaseCharsE.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92417 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 09:35:17 +00:00
Chris Lattner
33a1ec76c2 fix a miscompilation I introduced of cdecl with a late change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92416 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 09:22:13 +00:00
Chris Lattner
10d514ee58 enhance the compare/load/index optimization to work on *any* load
from a global with 32/64 elements or less (depending on whether
i64 is native on the target), generating a bitshift idiom to 
determine the result.  For example, on test4 we produce:

define i1 @test4(i32 %X) {
  %1 = lshr i32 933, %X                           ; <i32> [#uses=1]
  %2 = and i32 %1, 1                              ; <i32> [#uses=1]
  %R = icmp ne i32 %2, 0                          ; <i1> [#uses=1]
  ret i1 %R
}

This triggers in a number of interesting cases, for example, here's an
fp case:
@A.3255 = internal constant [4 x double] [double 4.100000e+00, double -3.900000e+00, double -1.000000e+00, double 1.000000e+00], align 32 ; <[4 x double]*> [#uses=7]
...
	   %7 = fcmp olt double %3, 0.000000e+00

In this case we make the slen2_tab global dead, which is nice:
@slen2_tab = internal constant [16 x i32] [i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 1, i32 2, i32 3, i32 1, i32 2, i32 3, i32 2, i32 3], align 32 ; <[16 x i32]*> [#uses=1]
...
	   %204 = icmp eq i32 %46, 0     

Perl has a bunch of these, also on the 'Perl_regkind' array:
@Perl_yygindex = internal constant [51 x i16] [i16 0, i16 0, i16 0, i16 0, i16 374, i16 351, i16 0, i16 -12, i16 0, i16 946, i16 413, i16 -83, i16 0, i16 0, i16 0, i16 -311, i16 -13, i16 4007, i16 2893, i16 0, i16 0, i16 0, i16 0, i16 0, i16 372, i16 -8, i16 0, i16 0, i16 246, i16 -131, i16 43, i16 86, i16 208, i16 -45, i16 -169, i16 987, i16 0, i16 0, i16 0, i16 0, i16 308, i16 0, i16 -271, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0], align 32 ; <[51 x i16]*> [#uses=1]
...
  %1364 = icmp eq i16 %1361, 0

186.crafty really likes this on 64-bit machines, because it triggers on a bunch of globals like this:
@white_outpost = internal constant [64 x i8] c"\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\02\00\00\00\00\00\04\05\05\04\00\00\00\00\03\06\06\03\00\00\00\00\00\01\01\00\00\00\00\00\00\00\00\00\00\00", align 32 ; <[64 x i8]*> [#uses=2]

However the big winner is 403.gcc, which triggers hundreds of times, eliminating all the accesses to the 57-element arrays 'mode_class', mode_unit_size, mode_bitsize, regclass_map, etc.

go 64-bit machines :)




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92415 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 08:56:52 +00:00
Chris Lattner
34e0c76f93 enhance the previous optimization to work with fcmp in addition
to icmp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92412 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 08:20:51 +00:00
Chris Lattner
1f12e44b62 Teach instcombine to fold compares of loads from constant
arrays with variable indices into a comparison of the index
with a constant.  The most common occurrence of this that
I see by far is stuff like:

if ("foobar"[i] == '\0') ...

which we compile into: if (i == 6), saving a load and 
materialization of the global address.  This also exposes 
loop trip count information to later passes in many cases.

This triggers hundreds of times in xalancbmk, which is where I first
noticed it, but it also triggers in many other apps.  Here are a few 
interesting ones from various apps:

@must_be_connected_without = internal constant [8 x i8*] [i8* getelementptr inbounds ([3 x i8]* @.str64320, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8]* @.str27283, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str71327, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str72328, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8]* @.str18274, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8]* @.str11267, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8]* @.str32288, i64 0, i64 0), i8* null], align 32 ; <[8 x i8*]*> [#uses=2]
  %scevgep.i = getelementptr [8 x i8*]* @must_be_connected_without, i64 0, i64 %indvar.i ; <i8**> [#uses=1]
  %17 = load ...
  %18 = icmp eq i8* %17, null                     ; <i1> [#uses=1]
-> icmp eq i64 %indvar.i, 7 


@yytable1095 = internal constant [84 x i8] c"\12\01(\05\06\07\08\09\0A\0B\0C\0D\0E1\0F\10\11266\1D: \10\11,-,0\03'\10\11B6\04\17&\18\1945\05\06\07\08\09\0A\0B\0C\0D\0E\1E\0F\10\11*\1A\1B\1C$3+>#%;<IJ=ADFEGH9KL\00\00\00C", align 32 ; <[84 x i8]*> [#uses=2]
  %57 = getelementptr inbounds [84 x i8]* @yytable1095, i64 0, i64 %56 ; <i8*> [#uses=1]
   %mode.0.in = getelementptr inbounds [9 x i32]* @mb_mode_table, i64 0, i64 %.pn ; <i32*> [#uses=1]
load ...
   %64 = icmp eq i8 %58, 4                         ; <i1> [#uses=1]
-> icmp eq i64 %.pn, 35             ; <i1> [#uses=0]


@gsm_DLB = internal constant [4 x i16] [i16 6554, i16 16384, i16 26214, i16 32767]
%scevgep.i = getelementptr [4 x i16]* @gsm_DLB, i64 0, i64 %indvar.i ; <i16*> [#uses=1]
%425 = load %scevgep.i
%426 = icmp eq i16 %425, -32768                 ; <i1> [#uses=0]
-> false



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92411 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 08:12:04 +00:00
Chris Lattner
0b178e25c4 remove the instcombine transformations that are inserting nasty
pointer to int casts that confuse later optimizations.  See PR3351
for details.

This improves but doesn't complete fix 483.xalancbmk because llvm-gcc
does this xform in GCC's "fold" routine as well.  Clang++ will do
better I guess.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92408 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02 00:31:05 +00:00
Chris Lattner
ec12d05019 add a simple instcombine xform, simplify another one to use hasAllZeroIndices()
instead of hand rolling a loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92403 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 23:09:08 +00:00
Chris Lattner
85c1c964dc generalize the pointer difference optimization to handle
a constantexpr gep on the 'base' side of the expression.
This completes comment #4 in PR3351, which comes from
483.xalancbmk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92402 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 22:42:29 +00:00
Chris Lattner
f2ebc682d1 teach instcombine to optimize pointer difference idioms involving constant
expressions.  This is a step towards comment #4 in PR3351.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92401 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 22:29:12 +00:00
Chris Lattner
3376718505 use 'match' to simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92400 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 22:12:03 +00:00
Chris Lattner
e33d413152 implement the transform requested in PR5284
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92398 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 18:34:40 +00:00
Chris Lattner
f9ead87c68 add missing line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92384 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 01:54:08 +00:00
Chris Lattner
d27f911b23 add a few trivial instcombines for llvm.powi.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92383 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 01:52:15 +00:00
Chris Lattner
9506c930aa When factoring multiply expressions across adds, factor both
positive and negative forms of constants together.  This 
allows us to compile:

int foo(int x, int y) {
    return (x-y) + (x-y) + (x-y);
}

into:

_foo:                                                       ## @foo
	subl	%esi, %edi
	leal	(%rdi,%rdi,2), %eax
	ret

instead of (where the 3 and -3 were not factored):

_foo:
        imull   $-3, 8(%esp), %ecx
        imull   $3, 4(%esp), %eax
        addl    %ecx, %eax
        ret

this started out as:
    movl    12(%ebp), %ecx
    imull   $3, 8(%ebp), %eax
    subl    %ecx, %eax
    subl    %ecx, %eax
    subl    %ecx, %eax
    ret

This comes from PR5359.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92381 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 01:13:15 +00:00
Chris Lattner
9046193e55 clean up some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92377 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 00:04:26 +00:00
Chris Lattner
f55e7f54b1 switch from std::map to DenseMap for rank data structures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92375 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 00:01:34 +00:00
Chris Lattner
3523993451 reuse negates where possible instead of always creating them from scratch.
This allows us to optimize test12 into:

define i32 @test12(i32 %X) {
  %factor = mul i32 %X, -3                        ; <i32> [#uses=1]
  %Z = add i32 %factor, 6                         ; <i32> [#uses=1]
  ret i32 %Z
}

instead of:

define i32 @test12(i32 %X) {
  %Y = sub i32 6, %X                              ; <i32> [#uses=1]
  %C = sub i32 %Y, %X                             ; <i32> [#uses=1]
  %Z = sub i32 %C, %X                             ; <i32> [#uses=1]
  ret i32 %Z
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92373 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 20:34:32 +00:00
Chris Lattner
f31e2e92a8 we don't need a smallptrset to detect duplicates, the values are
sorted, so we can just do a linear scan.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92372 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 19:49:01 +00:00
Chris Lattner
1e7558b656 make reassociate more careful about not leaving around dead mul's
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92370 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 19:34:45 +00:00
Chris Lattner
f8a447de16 remove debug
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92369 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 19:25:19 +00:00
Chris Lattner
69e98e2c0f teach reassociate to factor x+x+x -> x*3. While I'm at it,
fix RemoveDeadBinaryOp to actually do something.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92368 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 19:24:52 +00:00
Chris Lattner
9f7b7089be change reassociate to use SmallVector for its key datastructures
instead of std::vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 18:40:32 +00:00
Chris Lattner
9cd1bc4f8b change an if to an assert, fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92364 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 18:18:46 +00:00
Chris Lattner
94285e620b move the rest of the add optimization code out to OptimizeAdd,
improve some comments, simplify a bit of code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92363 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 18:17:13 +00:00
Chris Lattner
9fdaefad58 factor statistic updating better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 17:51:05 +00:00
Chris Lattner
13a754ce92 simple fix for an incorrect factoring which causes a
miscompilation, PR5458.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92354 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 08:33:49 +00:00
Chris Lattner
f3f55a9bc1 factor code out into helper functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92347 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 07:59:34 +00:00
Chris Lattner
8d93b259f6 switch some std::vector's to smallvector. Reduce nesting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 07:48:51 +00:00
Chris Lattner
ec531233a1 use more modern datastructures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92344 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 07:33:14 +00:00
Chris Lattner
1befe643b2 clean up -debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92343 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 07:17:37 +00:00
Chris Lattner
f0908a351a fix Analysis/DebugInfo.h to not include Metadata.h. Do this
by moving one method out of line and eliminating redundant checks
from other methods.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92337 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 03:02:08 +00:00
Chris Lattner
5d0cacdbb6 rename "elements" of metadata to "operands". "Elements" are
things that occur in types.  "operands" are things that occur
in values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92322 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 01:22:29 +00:00
Benjamin Kramer
fda08e1308 Use an array instead of a SmallVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-29 11:04:52 +00:00
Chris Lattner
19f2dc436d prune #includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92260 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-29 09:12:29 +00:00
Chris Lattner
081134741b Final step in the metadata API restructuring: move the
getMDKindID/getMDKindNames methods to LLVMContext (and add
convenience methods to Module), eliminating MetadataContext.
Move the state that it maintains out to LLVMContext.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92259 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-29 09:01:33 +00:00
Chris Lattner
101e2cab0b remove useless argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92256 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-29 08:03:58 +00:00
Chris Lattner
3990b121cf This is a major cleanup of the instruction metadata interfaces that
I asked Devang to do back on Sep 27.  Instead of going through the
MetadataContext class with methods like getMD() and getMDs(), just
ask the instruction directly for its metadata with getMetadata()
and getAllMetadata().

This includes a variety of other fixes and improvements: previously
all Value*'s were bloated because the HasMetadata bit was thrown into
value, adding a 9th bit to a byte.  Now this is properly sunk down to
the Instruction class (the only place where it makes sense) and it
will be folded away somewhere soon.

This also fixes some confusion in getMDs and its clients about 
whether the returned list is indexed by the MDID or densely packed.
This is now returned sorted and densely packed and the comments make
this clear.

This introduces a number of fixme's which I'll follow up on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-28 23:41:32 +00:00
Chris Lattner
a53cfd16f0 split code that doesn't need to be templated out of IRBuilder into a new
non-templated IRBuilderBase class.  Move that large CreateGlobalString
out of line, eliminating the need to #include GlobalVariable.h in IRBuilder.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92227 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-28 21:28:46 +00:00
Chris Lattner
0eb419800a rename getMDKind -> getMDKindID, make it autoinsert if an MD Kind
doesn't exist already, eliminate registerMDKind.  Tidy up a bunch
of random stuff.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92225 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-28 20:45:51 +00:00
Chris Lattner
5660846f15 Metadata.h doesn't need to include ValueHandle.h anymore.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92211 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-28 08:20:46 +00:00
Chris Lattner
8047d9a6be move an optimization for memcmp out of simplifylibcalls and into
SDISel.  This optimization was causing simplifylibcalls to 
introduce type-unsafe nastiness.  This is the first step, I'll be 
expanding the memcmp optimizations shortly, covering things that
we really really wouldn't want simplifylibcalls to do.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 00:37:38 +00:00
Chris Lattner
98d67d7d7e reorder to follow a normal fall-through style, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92084 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 23:24:51 +00:00
David Greene
63c9463c62 Remove dump routine and the associated Debug.h from a header. Patch up
other files to compensate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92075 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 22:58:38 +00:00
Eric Christopher
d060b2576a Update objectsize intrinsic and associated dependencies. Fix
lowering code and update testcases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91979 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 02:51:48 +00:00
Chris Lattner
aadadb3973 Fix the Convert to scalar to not insert dead loads in the store case. The
load is needed when we have a small store into a large alloca (at which 
point we get a load/insert/store sequence), but when you do a full-sized
store, this load ends up being dead.

This dead load is bad in really large nasty testcases where the load ends
up causing mem2reg to insert large chains of dependent phi nodes which only
ADCE can delete.  Instead of doing this, just don't insert the dead load.

This fixes rdar://6864035



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91917 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 19:33:28 +00:00
Chris Lattner
97eee027f9 fix some fixme's by using twines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91916 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 19:23:33 +00:00
Bob Wilson
f27a4cd783 Generalize SROA to allow the first index of a GEP to be non-zero. Add a
missing check that an array reference doesn't go past the end of the array,
and remove some redundant checks for in-bound array and vector references
that are no longer needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91897 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 06:57:14 +00:00
Chris Lattner
1a0e7081c3 Implement PR5795 by merging duplicated return blocks. This could go further
by merging all returns in a function into a single one, but simplifycfg 
currently likes to duplicate the return (an unfortunate choice!)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91890 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 06:07:30 +00:00
Chris Lattner
0ee443d169 The phi translated pointer can be computed when returning a partially cached result
instead of stored.  This reduces memdep memory usage, and also eliminates a bunch of
weakvh's.  This speeds up gvn on gcc.c-torture/20001226-1.c from 23.9s to 8.45s (2.8x)
on a different machine than earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 04:25:02 +00:00
Eric Christopher
f734be2ba4 Whitespace fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91875 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 01:23:51 +00:00
Daniel Dunbar
eddfaaf07e Add suggested parentheses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91853 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 23:27:57 +00:00
Chris Lattner
d2191e549b Add a fastpath to Load GVN to special case when we have exactly one dominating
load to avoid even messing around with SSAUpdate at all.  In this case (which
is very common, we can just use the input value directly).

This speeds up GVN time on gcc.c-torture/20001226-1.c from 36.4s to 16.3s,
which still isn't great, but substantially better and this is a simple speedup
that applies to lots of different cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 23:15:48 +00:00
Chris Lattner
5362c545e8 refactor some code out to a new helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91849 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 23:04:33 +00:00
Chris Lattner
25bceead50 improve indentation avoid a pointless conversion from weakvh to trackingvh,
no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91848 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 22:43:03 +00:00
Bob Wilson
3c3af5d155 Remove special-case SROA optimization of variable indexes to one-element and
two-element arrays.  After restructuring the SROA code, it was not safe to
do this without adding more checking.  It is not clear that this special-case
has really been useful, and removing this simplifies the code quite a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91828 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 18:39:47 +00:00
Chris Lattner
3cf4d90f3d revert r89298, which was committed without a testcase. I think
the underlying PHI node insertion issue in SSAUpdate is fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91821 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 07:45:57 +00:00
Chris Lattner
4c1e3da0cd fix PR5837 by having SSAUpdate reuse phi nodes for the
'GetValueInMiddleOfBlock' case, instead of inserting 
duplicates.

A similar fix is almost certainly needed by the machine-level
SSAUpdate implementation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91820 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 07:16:11 +00:00
Chris Lattner
b109b5c148 give instcombine some helper functions for matching MIN and MAX, and
implement some optimizations for MIN(MIN()) and MAX(MAX()) and 
MIN(MAX()) etc.  This substantially improves the code in PR5822 but
doesn't kick in much elsewhere.  2 max's were optimized in 
pairlocalalign and one in smg2000.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91814 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 06:03:05 +00:00
Chris Lattner
3bf6815556 enhance x-(-A) -> x+A to preserve NUW/NSW.
Use the presence of NSW/NUW to fold "icmp (x+cst), x" to a constant in
cases where it would otherwise be undefined behavior.

Surprisingly (to me at least), this triggers hundreds of the times in
a few benchmarks: lencode, ldecode, and 466.h264ref seem to *really*
like this.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91812 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 04:04:05 +00:00
Chris Lattner
2799bafb98 Optimize all cases of "icmp (X+Cst), X" to something simpler. This triggers
a bunch in lencode, ldecod, spass, 176.gcc, 252.eon, among others.  It is 
also the first part of PR5822


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91811 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 03:19:28 +00:00
Douglas Gregor
cabdd7425d Fix a bunch of little errors that Clang complains about when its being pedantic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 07:05:23 +00:00
Chris Lattner
0ebc6ce974 fix PR5827 by disabling the phi slicing transformation in a case
where instcombine would have to split a critical edge due to a
phi node of an invoke.  Since instcombine can't change the CFG,
it has to bail out from doing the transformation.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91763 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 07:01:15 +00:00
Bob Wilson
e88728d757 Update my SROA changes in response to review.
* change FindElementAndOffset to return a uint64_t instead of unsigned, and
  to identify the type to be used for that result in a GEP instruction.
* move "isa<ConstantInt>" to be first in conditional.
* replace some dyn_casts with casts.
* add a comment about handling mem intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91762 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 06:53:17 +00:00
Bob Wilson
b742defa0a Reapply 91459 with a simple fix for the problem that broke the x86_64-darwin
bootstrap.  This also replaces the WeakVH references that Chris objected to
with normal Value references.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91711 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 20:14:40 +00:00
Eli Friedman
97b087c778 Optimize icmp of null and select of two constants even if the select has
multiple uses.  (The construct in question was found in gcc.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91675 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 08:22:35 +00:00
Dan Gohman
ad12b2698b Eliminte unnecessary uses of <cstdio>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91666 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 03:25:51 +00:00
Dan Gohman
92329c7fbe Add Loop contains utility methods for testing whether a loop
contains another loop, or an instruction. The loop form is
substantially more efficient on large loops than the typical
code it replaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91654 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 01:24:09 +00:00
Dan Gohman
3ca735450d Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91653 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 01:20:44 +00:00
Dan Gohman
6a27e1550d Don't pass const pointers by reference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91647 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 00:38:08 +00:00
Dan Gohman
34d2b90d09 Update a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91645 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 00:28:43 +00:00
Dan Gohman
6bec5bb344 Reapply LoopStrengthReduce and IVUsers cleanups, excluding the part
of 91296 that caused trouble -- the Processed list needs to be
preserved for the livetime of the pass, as AddUsersIfInteresting
is called from other passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91641 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 00:06:20 +00:00
Eli Friedman
b17cb06c35 Allow instcombine to combine "sext(a) >u const" to "a >u trunc(const)".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91631 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 22:42:29 +00:00
Eli Friedman
8e4b197e0b Make the ptrtoint comparison simplification work if one side is a global.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91624 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 21:27:47 +00:00
Eli Friedman
0c826d98b3 Slightly generalize transformation of memmove(a,a,n) so that it also applies
to memcpy. (Such a memcpy is technically illegal, but in practice is safe
and is generated by struct self-assignment in C code.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 21:07:31 +00:00
Bob Wilson
39c88a641b Re-revert 91459. It's breaking the x86_64 darwin bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91607 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 18:34:24 +00:00
Evan Cheng
04149f7ffd Revert 91280-91283, 91286-91289, 91291, 91293, 91295-91296. It apparently introduced a non-deterministic behavior in the optimizer somewhere.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 09:39:49 +00:00
Daniel Dunbar
2674089cef Reapply r91459, it was only unmasking the bug, and since TOT is still broken having it reverted does no good.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 20:09:53 +00:00
Daniel Dunbar
fca55c8ac7 Revert "Reapply 91184 with fixes and an addition to the testcase to cover the
problem", this broke llvm-gcc bootstrap for release builds on
x86_64-apple-darwin10.

This reverts commit db22309800b224a9f5f51baf76071d7a93ce59c9.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91534 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 10:56:17 +00:00
Chris Lattner
24604110ef reapply my strstr optimization. I have reproduced the x86-64 bootstrap
miscompile (i386.o miscompares) but it happens both with and without
this patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91532 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 09:32:05 +00:00
Chris Lattner
0001517d9d revert my strstr optimization, I'm told it breaks x86-64 bootstrap.
Will reapply with a fix when I get a chance.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91486 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 00:46:02 +00:00
Bob Wilson
970eaf2520 Reapply 91184 with fixes and an addition to the testcase to cover the problem
found last time.  Instead of trying to modify the IR while iterating over it,
I've change it to keep a list of WeakVH references to dead instructions, and
then delete those instructions later.  I also added some special case code to
detect and handle the situation when both operands of a memcpy intrinsic are
referencing the same alloca.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91459 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 22:00:51 +00:00
Chris Lattner
ad6b1fdaf9 optimize strstr, PR5783
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91438 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 19:14:40 +00:00
Dan Gohman
a0cefcfcac Delete an unused function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91432 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 16:30:09 +00:00
Chris Lattner
099b41f342 add some other xforms that should be done as part of PR5783
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 09:05:13 +00:00
Chris Lattner
4bbf4ee149 Remove isPod() from DenseMapInfo, splitting it out to its own
isPodLike type trait.  This is a generally useful type trait for
more than just DenseMap, and we really care about whether something
acts like a pod, not whether it really is a pod.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 07:26:43 +00:00
Dan Gohman
30844c3950 Fix a thinko; isNotAlreadyContainedIn had a built-in negative, so the
condition was inverted when the code was converted to contains().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91295 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 17:31:01 +00:00
Dan Gohman
c71c0e958c Remove unnecessary #includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91293 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 17:19:06 +00:00
Dan Gohman
d3222b4224 Instead of having a ScalarEvolution pointer member in BasedUser, just pass
the ScalarEvolution pointer into the functions which need it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91289 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 17:12:51 +00:00
Dan Gohman
a77d588c75 Don't bother cleaning up if there's nothing to clean up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91288 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 17:10:44 +00:00
Dan Gohman
6dc1ef3923 Delete an unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91287 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 17:08:09 +00:00
Dan Gohman
1ed8bb3556 LSR itself doesn't need LoopInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 17:02:34 +00:00
Dan Gohman
c398365349 LSR itself doesn't need DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91282 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 16:57:08 +00:00
Dan Gohman
67b94fb73d Remove the code in LSR that manually hoists expansions out of loops;
SCEVExpander does this automatically.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91281 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 16:52:55 +00:00
Dan Gohman
b058ceda56 Minor code cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91280 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 16:37:29 +00:00
Chris Lattner
a59adc4015 revert r91184, because it causes a crash on a .bc file I just
sent to Bob.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91268 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 05:11:02 +00:00
Chandler Carruth
0daf77e803 Don't leave pointers uninitialized in the default constructor. GCC complains
about the potential use of these uninitialized members under certain conditions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91239 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-13 07:04:45 +00:00
Bob Wilson
73a1b67cb9 Revise scalar replacement to be more flexible about handle bitcasts and GEPs.
While scanning through the uses of an alloca, keep track of the current offset
relative to the start of the alloca, and check memory references to see if
the offset & size correspond to a component within the alloca.  This has the
nice benefit of unifying much of the code from isSafeUseOfAllocation,
isSafeElementUse, and isSafeUseOfBitCastedAllocation.  The code to rewrite
the uses of a promoted alloca, after it is determined to be safe, is
reorganized in the same way.

Also, when rewriting GEP instructions, mark them as "in-bounds" since all the
indices are known to be safe.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-11 23:47:40 +00:00
Eric Christopher
3472ae1e7b Make sure the immediate dominator isn't NULL through iterations
of the loop. We could get to this condition via indirect
branches.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91009 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-10 00:25:41 +00:00
Chris Lattner
16f244e982 Fix PR5744, a case where we were getting the pointer size instead of the
value size.  This only manifested when memdep inprecisely returns clobber,
which is do to a caching issue in the PR5744 testcase.  We can 'efficiently
emulate' this by using '-no-aa'


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91004 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-10 00:11:45 +00:00
Chris Lattner
b6760b4a1e allow this to build when the #if 0's are enabled. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90999 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-10 00:04:46 +00:00
Dan Gohman
f68d0c1bbe Dereference loopHeader after checking for null rather than before.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 22:55:01 +00:00
Chris Lattner
af064aeee6 fix hte last remaining known (by me) phi translation bug. When we reanalyze
clobbers to forward pieces of large stores to small loads, we need to consider
the properly phi translated pointer in the store block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90978 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 18:21:46 +00:00
Chris Lattner
b2c6ae8c0b change GetStoreValueForLoad to use IRBuilder, which is cleaner and
implicitly constant folds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90977 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 18:13:28 +00:00
Bob Wilson
efc58e7933 Fix a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90975 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 18:05:27 +00:00
Chris Lattner
4ca70fe15f change AnalyzeLoadFromClobberingMemInst/AnalyzeLoadFromClobberingStore
to require the load ty/ptr to be passed in, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90960 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 07:37:07 +00:00
Chris Lattner
03f17da4da change AnalyzeLoadFromClobberingWrite and clients to pass in type
and pointer instead of the load.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90959 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 07:34:10 +00:00
Chris Lattner
e18b97121c change NonLocalDepEntry from being a typedef for an std::pair to be its
own small class.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90956 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 07:08:01 +00:00
Chris Lattner
b3f927f6dd add some aborts to #if 0's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90929 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 02:41:54 +00:00
Chris Lattner
05e15f8897 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90926 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 01:59:31 +00:00
Bob Wilson
65ab34f3f2 Some superficial cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 18:27:03 +00:00
Bob Wilson
78c50b8cd6 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 18:22:03 +00:00
Duncan Sands
7a154cf228 Teach GlobalOpt to delete aliases with internal linkage (after
forwarding any uses).  GlobalDCE can also do this, but is only
run at -O3.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90850 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 10:10:20 +00:00
Nick Lewycky
87f8e49027 Remove unnecessary #include "llvm/LLVMContext.h".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90836 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 05:45:41 +00:00
Chris Lattner
08bc2701a2 fix PR5698
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90708 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 17:17:23 +00:00
Chris Lattner
bc9a28dd54 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90698 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 05:29:56 +00:00
Chris Lattner
cb9cbc4949 add support for forwarding mem intrinsic values to non-local loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90697 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 04:54:31 +00:00
Chris Lattner
faf815b938 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.  



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90695 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 01:57:02 +00:00
Nick Lewycky
83e8ec73e1 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).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90646 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-05 05:00:00 +00:00
Bob Wilson
39fdd6947c Fix up some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90603 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-04 21:57:37 +00:00
Bob Wilson
d614a1f0a8 Fix 80-column violations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-04 21:51:35 +00:00
Chris Lattner
45305d4ff6 add an assert to make it really clear what this is doing. Return singularval as
a compile time perf optimization to avoid a load.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90507 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-04 01:03:32 +00:00
Bob Wilson
4a8ee23a81 Fix a comment typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90487 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 21:47:07 +00:00
Owen Anderson
c9f2027adb Fix this crasher, and add a FIXME for a missed optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90408 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 03:43:29 +00:00
Chris Lattner
7896c9f436 improve portability to avoid conflicting with std::next in c++'0x.
Patch by Howard Hinnant!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90365 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 00:50:42 +00:00
Jim Grosbach
43a8241b65 Move EliminateDuplicatePHINodes() from SimplifyCFG.cpp to Local.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90324 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 17:06:45 +00:00
Andreas Neustifter
059a983531 Cheap, mostly strict, stable sorting.
This is necessary for tests so the results are comparable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90320 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 15:57:15 +00:00
Owen Anderson
9ff5a23186 Cleanup/remove some parts of the lifetime region handling code in memdep and GVN,
per Chris' comments.  Adjust testcases to match.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90304 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 07:35:19 +00:00
Chris Lattner
720e790480 factor some code better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90299 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 06:44:58 +00:00
Chris Lattner
65a9ab4f8f formatting cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90298 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 06:35:55 +00:00
Chris Lattner
bf796323b2 tidy up, remove dependence on order of evaluation of function args from EmitMemCpy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90297 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 06:05:42 +00:00
Chris Lattner
46875c0bfb fix PR5640 by tracking whether a block is the header of a loop more
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
2009-12-01 06:04:43 +00:00
Benjamin Kramer
e6f329476c Revert r90089 for now, it's breaking selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90097 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-29 21:17:48 +00:00
Benjamin Kramer
4aac07e898 Fix two FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90089 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-29 20:29:30 +00:00
Chris Lattner
cd188e9665 add testcases for the foo_with_overflow op xforms added recently and
fix bugs exposed by the tests.  Testcases from Alastair Lynn!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90056 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-29 02:57:29 +00:00
Chris Lattner
3f40e23392 Implement PR5634.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90046 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-29 00:51:17 +00:00
Chris Lattner
0c264b16b0 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28 16:08:18 +00:00
Chris Lattner
dd696052f0 Enhance InsertPHITranslatedPointer to be able to return a list of newly
inserted instructions.  No functionality change until someone starts using it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90039 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28 15:39:14 +00:00