Commit Graph

3721 Commits

Author SHA1 Message Date
Devang Patel 9b4127349c Follow LLVM coding style.
clang uses DBuilder, so it requries corresponding change.

llvm-svn: 126231
2011-02-22 18:56:12 +00:00
Benjamin Kramer 5b7a4e0195 Move "A | ~(A & ?) -> -1" from InstCombine to InstructionSimplify.
llvm-svn: 126082
2011-02-20 15:20:01 +00:00
Chris Lattner acf6b0776a Stores of null pointers should turn into memset, we weren't recognizing
them as splat values.

llvm-svn: 126041
2011-02-19 19:35:49 +00:00
Oscar Fuentes 5ed962656c Move library stuff out of the toplevel CMakeLists.txt file.
llvm-svn: 125968
2011-02-18 22:06:14 +00:00
Devang Patel 4ab0852080 Move DbgInfoPrinter specific utlities inside DbgInfoPrinter.cpp
llvm-svn: 125571
2011-02-15 17:36:11 +00:00
Devang Patel 27924da676 Print function info. Patch by Minjang Kim.
llvm-svn: 125567
2011-02-15 17:24:56 +00:00
Chris Lattner 69229316aa convert ConstantVector::get to use ArrayRef.
llvm-svn: 125537
2011-02-15 00:14:00 +00:00
Chris Lattner 34442e6ebf revert my ConstantVector patch, it seems to have made the llvm-gcc
builders unhappy.

llvm-svn: 125504
2011-02-14 18:15:46 +00:00
Chris Lattner d9f5b88548 Switch ConstantVector::get to use ArrayRef instead of a pointer+size
idiom.  Change various clients to simplify their code.

llvm-svn: 125487
2011-02-14 07:55:32 +00:00
Duncan Sands b86070933f Remove pointless blank line.
llvm-svn: 125463
2011-02-13 18:11:05 +00:00
Duncan Sands d114ab331c Teach instsimplify that X+Y>=X+Z is the same as Y>=Z if neither side overflows,
plus some variations of this.  According to my auto-simplifier this occurs a lot
but usually in combination with max/min idioms.  Because max/min aren't handled
yet this unfortunately doesn't have much effect in the testsuite.

llvm-svn: 125462
2011-02-13 17:15:40 +00:00
Chris Lattner 4f23f2be15 teach SCEV that the scale and addition of an inbounds gep don't NSW.
This fixes a FIXME in scev-aa.ll (allowing a new no-alias result) and
generally makes things more precise.

llvm-svn: 125449
2011-02-13 03:14:49 +00:00
Chris Lattner 7936a8a488 Per discussion with Dan G, inbounds geps *certainly* can have
unsigned overflow (e.g. "gep P, -1"), and while they can have
signed wrap in theoretical situations, modelling an AddRec as
not having signed wrap is going enough for any case we can 
think of today.  In the future if this isn't enough, we can
revisit this.  Modeling them as having NUW isn't causing any
known problems either FWIW.

llvm-svn: 125410
2011-02-11 21:43:33 +00:00
Nick Lewycky ac0b62c277 Tolerate degenerate phi nodes that can occur in the middle of optimization
passes. Fixes PR9112. Patch by Jakub Staszak!

llvm-svn: 125319
2011-02-10 23:54:10 +00:00
Duncan Sands 8b4e283bfb Formatting and comment tweaks.
llvm-svn: 125200
2011-02-09 17:45:03 +00:00
Chris Lattner 9e4aa0259f Teach instsimplify some tricks about exact/nuw/nsw shifts.
improve interfaces to instsimplify to take this info.

llvm-svn: 125196
2011-02-09 17:15:04 +00:00
Chris Lattner b940091388 Rework InstrTypes.h so to reduce the repetition around the NSW/NUW/Exact
versions of creation functions.  Eventually, the "insertion point" versions
of these should just be removed, we do have IRBuilder afterall.

Do a massive rewrite of much of pattern match.  It is now shorter and less
redundant and has several other widgets I will be using in other patches.
Among other changes, m_Div is renamed to m_IDiv (since it only matches 
integer divides) and m_Shift is gone (it used to match all binops!!) and
we now have m_LogicalShift for the one client to use.

Enhance IRBuilder to have "isExact" arguments to things like CreateUDiv
and reduce redundancy within IRbuilder by having these methods chain to
each other more instead of duplicating code.

llvm-svn: 125194
2011-02-09 17:00:45 +00:00
Duncan Sands 867cb633b4 Add an m_Div pattern for matching either a udiv or an sdiv and use it
to simplify the "(X/Y)*Y->X when the division is exact" transform.

llvm-svn: 125004
2011-02-07 09:36:32 +00:00
Chris Lattner 6e57b15228 teach instsimplify to transform (X / Y) * Y to X
when the div is an exact udiv.

llvm-svn: 124994
2011-02-06 22:05:31 +00:00
Eric Christopher b54605b8e2 Remove premature optimization that avoided calculating argument weights
if we weren't going to inline the function. The rest of the code using
this was removed.

Fixes PR9154.

llvm-svn: 124991
2011-02-06 21:27:46 +00:00
Anders Carlsson ecf8e159e3 Simplify test, as suggested by Chris.
llvm-svn: 124990
2011-02-06 20:22:49 +00:00
Anders Carlsson d21b06a0db When loading from a constant, fold inttoptr if the integer type and the resulting pointer type both have the same size.
llvm-svn: 124987
2011-02-06 20:11:56 +00:00
Anders Carlsson 36c6d23074 Fix another warning.
llvm-svn: 124961
2011-02-05 18:33:43 +00:00
Eric Christopher ceb4671ddd Fix cut and paste error spotted by Jakob.
llvm-svn: 124930
2011-02-05 02:48:47 +00:00
Eric Christopher 2dfbd7e0c1 Rewrite how the indirect call bonus is handled. This now works by:
a) Making it a per call site bonus for functions that we can move from
indirect to direct calls.
b) Reduces the bonus from 500 to 100 per call site.
c) Subtracts the size of the possible newly inlineable call from the
bonus to only add a bonus if we can inline a small function to devirtualize
it.

Also changes the bonus from a positive that's subtracted to a negative
that's added.

Fixes the remainder of rdar://8546196 by reducing the object file size
after inlining by 84%.

llvm-svn: 124916
2011-02-05 00:49:15 +00:00
Duncan Sands 06504025d2 Improve threading of comparisons over select instructions (spotted by my
auto-simplifier).  This has a big impact on Ada code, but not much else.
Unfortunately the impact is mostly negative!  This is due to PR9004 (aka
SCCP failing to resolve conditional branch conditions in the destination
blocks of the branch), in which simple correlated expressions are not
resolved but complicated ones are, so simplifying has a bad effect!

llvm-svn: 124788
2011-02-03 09:37:39 +00:00
Devang Patel df0dd7dc69 Fix typo in comment.
llvm-svn: 124759
2011-02-03 00:13:47 +00:00
Devang Patel be933b470a Add support to describe template value parameter in debug info.
llvm-svn: 124755
2011-02-02 22:35:53 +00:00
Devang Patel 3a9e65efb6 Add support to describe template parameter type in debug info.
llvm-svn: 124752
2011-02-02 21:38:25 +00:00
Duncan Sands 5747abab10 Reenable the transform "(X*Y)/Y->X" when the multiplication is known not to
overflow (nsw flag), which was disabled because it breaks 254.gap.  I have
informed the GAP authors of the mistake in their code, and arranged for the
testsuite to use -fwrapv when compiling this benchmark.

llvm-svn: 124746
2011-02-02 20:52:00 +00:00
Duncan Sands a29ea9aa4c Add a m_Undef pattern for convenience. This is so that code that uses
pattern matching can also pattern match undef, creating a more uniform
style.

llvm-svn: 124657
2011-02-01 09:06:20 +00:00
Duncan Sands 4b397fcdc2 Add a m_SignBit pattern for convenience.
llvm-svn: 124656
2011-02-01 08:50:33 +00:00
Duncan Sands cf0ff030a8 Have m_One also match constant vectors for which every element is 1.
llvm-svn: 124655
2011-02-01 08:39:12 +00:00
Eric Christopher 46308e666a Reapply 124275 since the Dragonegg failure was unreproducible.
llvm-svn: 124641
2011-02-01 01:16:32 +00:00
Duncan Sands 2e5a58da8f Commit 124487 broke 254.gap. See if disabling the part that might be triggered
by PR9088 fixes things.

llvm-svn: 124561
2011-01-30 18:24:20 +00:00
Duncan Sands b67edc6a29 Transform (X/Y)*Y into X if the division is exact. Instcombine already knows how
to do this and more, but would only do it if X/Y had only one use.  Spotted as the
most common missed simplification in SPEC by my auto-simplifier, now that it knows
about nuw/nsw/exact flags.  This removes a bunch of multiplications from 447.dealII
and 483.xalancbmk.  It also removes a lot from tramp3d-v4, which results in much
more inlining.

llvm-svn: 124560
2011-01-30 18:03:50 +00:00
Nick Lewycky b89d9a4412 Fix comment.
llvm-svn: 124544
2011-01-29 19:55:23 +00:00
Frits van Bommel c2549661af Move InstCombine's knowledge of fdiv to SimplifyInstruction().
llvm-svn: 124534
2011-01-29 15:26:31 +00:00
Duncan Sands 2e9e4f1be3 Fix typo: should have been testing that X was odd, not V.
llvm-svn: 124533
2011-01-29 13:27:00 +00:00
Andrew Trick 24f5ff0f23 Implementation of path profiling.
Modified patch by Adam Preuss.

This builds on the existing framework for block tracing, edge profiling and optimal edge profiling.
See -help-hidden for new flags.
For documentation, see the technical report "Implementation of Path Profiling..." in llvm.org/pubs.

llvm-svn: 124515
2011-01-29 01:09:53 +00:00
Duncan Sands e4b4d0c16d This dyn_cast should be a cast. Pointed out by Frits van Bommel.
llvm-svn: 124497
2011-01-28 18:53:08 +00:00
Duncan Sands 65995fa2a0 Thread divisions over selects and phis. This doesn't fire much and has basically
zero effect on the testsuite (it improves two Ada testcases).

llvm-svn: 124496
2011-01-28 18:50:50 +00:00
Duncan Sands 771e82a863 My auto-simplifier noticed that ((X/Y)*Y)/Y occurs several times in SPEC
benchmarks, and that it can be simplified to X/Y.  (In general you can only
simplify (Z*Y)/Y to Z if the multiplication did not overflow; if Z has the
form "X/Y" then this is the case).  This patch implements that transform and
moves some Div logic out of instcombine and into InstructionSimplify.
Unfortunately instcombine gets in the way somewhat, since it likes to change
(X/Y)*Y into X-(X rem Y), so I had to teach instcombine about this too.
Finally, thanks to the NSW/NUW flags, sometimes we know directly that "Z*Y"
does not overflow, because the flag says so, so I added that logic too.  This
eliminates a bunch of divisions and subtractions in 447.dealII, and has good
effects on some other benchmarks too.  It seems to have quite an effect on
tramp3d-v4 but it's hard to say if it's good or bad because inlining decisions
changed, resulting in massive changes all over.

llvm-svn: 124487
2011-01-28 16:51:11 +00:00
Eric Christopher cd55a46c31 Temporarily revert 124275 to see if it brings the dragonegg buildbot back.
llvm-svn: 124312
2011-01-26 19:40:31 +00:00
Duncan Sands 8a33733228 APInt has a method for determining whether a number is a power of 2
which is more efficient than countPopulation - use it.

llvm-svn: 124283
2011-01-26 08:44:16 +00:00
Nick Lewycky d9e6b4a8ff Fix memory corruption. If one of the SCEV creation functions calls another but
doesn't return immediately after then the insert position in UniqueSCEVs will
be out of date. No test because this is a memory corruption issue. Fixes PR9051!

llvm-svn: 124282
2011-01-26 08:40:22 +00:00
Eric Christopher 078159e310 Separate out the constant bonus from the size reduction metrics. Rework
a few loops accordingly. Should be no functional change.

This is a step for more accurate cost/benefit analysis of devirt/inlining
bonuses.

llvm-svn: 124275
2011-01-26 02:58:39 +00:00
Eric Christopher 58f157a677 Coding style formatting changes.
llvm-svn: 124260
2011-01-26 01:09:59 +00:00
Duncan Sands 9e9d5b25e2 In which I discover that zero+zero is zero, d'oh!
llvm-svn: 124188
2011-01-25 15:14:15 +00:00
Duncan Sands fced7620f5 See if this fixes llvm-gcc bootstrap.
llvm-svn: 124184
2011-01-25 12:15:09 +00:00