1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 12:33:33 +02:00
Commit Graph

36 Commits

Author SHA1 Message Date
Craig Topper
f09596e2d8 [ConstantRange] Fix a couple cases where we were possibly throwing away an APInt allocation we could reuse. NFC
This uses setAllBits to replace getMaxValue and operator=(uint64_t) instead of constructing an APInt from uint64_t.

llvm-svn: 301761
2017-04-30 00:44:05 +00:00
Craig Topper
75fea92e18 [ConstantRange] Use APInt::getOneBitSet to shorten some code. NFC
llvm-svn: 301753
2017-04-29 17:59:41 +00:00
Craig Topper
70a5e53ec7 [ConstantRange] Replace getMaxValue+zext with getLowBitsSet. Replace zero-init+setBit with getOneBitSet. NFC
llvm-svn: 301752
2017-04-29 17:46:13 +00:00
Craig Topper
c86dc13c7a [ConstantRange] Use APInt::operator-= to remove temporary APInts.
llvm-svn: 301751
2017-04-29 17:46:11 +00:00
Craig Topper
b3c4f0e61c [ConstantRange] Use ternary operator instead of 'if' to avoid copying an APInt and then possibly copying over it.
llvm-svn: 301741
2017-04-29 07:24:13 +00:00
Craig Topper
9b70a2d2af [ConstantRange] Add std::move to a bunch of places that pass local APInts to ConstantRange constructor.
The ConstantRange constructor takes APInt by value so without these moves we are making copies.

llvm-svn: 301740
2017-04-29 06:40:47 +00:00
Craig Topper
87c29d5fac [ConstantRange] Remove a temporary APInt I meant to delete in r300621. NFC
llvm-svn: 301737
2017-04-29 05:24:34 +00:00
Craig Topper
fb1e8e7664 [ConstantRange] Improve the efficiency of one of the ConstantRange constructors.
We were default constructing the Lower/Upper APInts. Then creating min or max value, then doing a move assignment to Lower and copy assignment to upper. The copy assignment operator in particular has an out of line function call that has to examine whether or not a previous allocation exists that can be reused which of course it can't in this case.

The new code creates the min/max value first, move constructs Lower from it then copy constructs Upper from Lower.

This also seems to have convinced a self host build that this constructor can be inlined more readily into other methods in ConstantRange.

llvm-svn: 301736
2017-04-29 05:08:52 +00:00
Craig Topper
e815e9541f [ConstantRange] Use APInt::isNullValue rather than APInt::isMinValue where it would make more sense to thing of 0 as 0 rather than the minimum unsigned value. NFC
llvm-svn: 301696
2017-04-28 21:48:09 +00:00
Craig Topper
0b1ad24c87 [ConstantRange] Use const references to prevent a couple APInt copies. NFC
llvm-svn: 301694
2017-04-28 21:48:03 +00:00
Craig Topper
1c6b3b5c27 [ConstantRange] Optimize APInt creation in getSignedMax/getSignedMin.
We were creating an APInt at the top of these methods that isn't always returned. For ranges wider than 64-bits this results in an allocation and deallocation when its not used.

In getSignedMax we were creating Upper-1 to use in a compare and then creating it again for a return value. The compiler is unable to determine that these can be shared. So help it out and create the Upper-1 in a temporary that can be reused.

This provides a little compile time improvement.

llvm-svn: 300621
2017-04-18 23:02:39 +00:00
Sanjay Patel
2d612df495 [ConstantRange] fix doxygen comment formatting; NFC
llvm-svn: 300554
2017-04-18 14:27:24 +00:00
Craig Topper
82782780bb [IR] Remove the APIntMoveTy typedef from ConstantRange. Use APInt type directly.
This typedef used to be conditional based on whether rvalue references were supported. Looks like it got left behind when we switched to always having rvalue references with c++11. I don't think it provides any value now.

llvm-svn: 300146
2017-04-13 00:20:31 +00:00
Michael Zolotukhin
978da1ce40 [ConstantRange] Add setSizeSmallerThanOf method.
Summary:
ConstantRange class currently has a method getSetSize, which is mostly used to
compare set sizes of two constant ranges (there is only one spot where it's used
in a slightly different scenario). This patch introduces setSizeSmallerThanOf
method, which does such comparison in a more efficient way. In the original
method we have to extend our types to (BitWidth+1), which can result it using
slow case of APInt, extra memory allocations, etc.

The change is supposed to not change any functionality, but it slightly improves
compile time. Here is compile time improvements that I observed on CTMark:
* tramp3d-v4	-2.02%
* pairlocalalign	-1.82%
* lencod	-1.67%

Reviewers: sanjoy, atrick, pete

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31104

llvm-svn: 298236
2017-03-20 06:33:07 +00:00
Matthias Braun
5809e12d46 Cleanup dump() functions.
We had various variants of defining dump() functions in LLVM. Normalize
them (this should just consistently implement the things discussed in
http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html

For reference:
- Public headers should just declare the dump() method but not use
  LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- The definition of a dump method should look like this:
  #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void MyClass::dump() {
    // print stuff to dbgs()...
  }
  #endif

llvm-svn: 293359
2017-01-28 02:02:38 +00:00
Philip Reames
66a2409cf2 Factor out common parts of LVI and Float2Int into ConstantRange [NFCI]
This just extracts out the transfer rules for constant ranges into a single shared point. As it happens, neither bit of code actually overlaps in terms of the handled operators, but with this change that could easily be tweaked in the future.

I also want to have this separated out to make experimenting with a eager value info implementation and possibly a ValueTracking-like fixed depth recursion peephole version. There's no reason all four of these can't share a common implementation which reduces the chances of bugs.

Differential Revision: https://reviews.llvm.org/D27294

llvm-svn: 288413
2016-12-01 20:08:47 +00:00
Peter Collingbourne
cec8c686b3 Analysis: Move llvm::getConstantRangeFromMetadata to IR library.
We're about to start using it there.

Differential Revision: https://reviews.llvm.org/D25877

llvm-svn: 284865
2016-10-21 19:59:26 +00:00
Artur Pilipenko
6a0a975738 Introduce ConstantRange.addWithNoSignedWrap
To be used by upcoming change to IndVarSimplify

Reviewed By: sanjoy

Differential Revision: https://reviews.llvm.org/D25732

llvm-svn: 284597
2016-10-19 14:44:23 +00:00
Sanjoy Das
26178861cc [ConstantRange] Make getEquivalentICmp smarter
This change teaches getEquivalentICmp to be smarter about generating
ICMP_NE and ICMP_EQ predicates.

An earlier version of this change was landed as rL283057 which had a
use-after-free bug.  This new version has a fix for that bug, and a (C++
unittests/) test case that would have triggered it rL283057.

llvm-svn: 283078
2016-10-02 20:59:05 +00:00
Sanjoy Das
ce09fb6c0a Revert r283057 and r283058
They've broken the sanitizer-bootstrap bots.  Reverting while I investigate.

Original commit messages:

r283057: "[ConstantRange] Make getEquivalentICmp smarter"

r283058: "[SCEV] Rely on ConstantRange instead of custom logic; NFCI"
llvm-svn: 283062
2016-10-02 02:40:27 +00:00
Sanjoy Das
2915cf67fe [ConstantRange] Make getEquivalentICmp smarter
This change teaches getEquivalentICmp to be smarter about generating
ICMP_NE and ICMP_EQ predicates.

llvm-svn: 283057
2016-10-02 00:09:49 +00:00
Sanjay Patel
a0a797b7f0 fix formatting, typo; NFC
llvm-svn: 273118
2016-06-19 17:20:27 +00:00
Nick Lewycky
3ff4515717 Fix spelling and capitalization in comments. NFC
llvm-svn: 271862
2016-06-06 01:51:23 +00:00
Pete Cooper
4b16ddde7a Don't generate unnecessary signed ConstantRange during multiply. NFC
r231483 taught ConstantRange::multiply to be clever about signed vs unsigned ranges. For example, an unsigned range could be full-set while the signed range is more specific than that.

In looking at the allocations trace for LTO'ing verify-uselistorder (see r236629 for details), millions of allocations are from APInt, many of which come from ConstantRange's.

This change tries to avoid some (3.2 million) allocations by returning the unsigned range if its suitable. The checks here are that it should not be a wrapping range, and should be positive. That should be enough to check for ranges such as [1, 10) which the signed range will be equal to, if we were to calculate it.

Differential Revision: http://reviews.llvm.org/D20723

Reviewed by James Molloy

llvm-svn: 271020
2016-05-27 17:06:50 +00:00
Sanjoy Das
c63bcd9d33 [ConstantRange] Add an getEquivalentICmp helper
Currently only its unit test uses it, but this will be used in a later
change to simplify some logic in the GuardWidening pass.

llvm-svn: 270018
2016-05-19 03:53:06 +00:00
Balaram Makam
8a2614ed09 "Reapply r268521 "[InstCombine] Canonicalize icmp instructions based on dominating conditions.""
This reapplies commit r268521, that was reverted in r268530 due to a test failure in select-implied.ll
Modified the test case to reflect the new change.

llvm-svn: 268557
2016-05-04 21:32:14 +00:00
Balaram Makam
6df288fe78 Revert "[InstCombine] Canonicalize icmp instructions based on dominating conditions."
This reverts commit 573a40f79b35cf3e71db331bb00f6a84f03b835d.

llvm-svn: 268530
2016-05-04 18:37:35 +00:00
Balaram Makam
93aa5a1614 [InstCombine] Canonicalize icmp instructions based on dominating conditions.
Summary:
    This patch canonicalizes conditions based on the constant range information
    of the dominating branch condition.
    For example:

      %cmp = icmp slt i64 %a, 0
      br i1 %cmp, label %land.lhs.true, label %lor.rhs
      lor.rhs:
        %cmp2 = icmp sgt i64 %a, 0

    Would now be canonicalized into:

      %cmp = icmp slt i64 %a, 0
      br i1 %cmp, label %land.lhs.true, label %lor.rhs
      lor.rhs:
        %cmp2 = icmp ne i64 %a, 0

Reviewers: mcrosier, gberry, t.p.northover, llvm-commits, reames, hfinkel, sanjoy, majnemer

Subscribers: MatzeB, majnemer, mcrosier

Differential Revision: http://reviews.llvm.org/D18841

llvm-svn: 268521
2016-05-04 17:34:20 +00:00
Sanjoy Das
53336f6738 [ConstantRange] Generalize makeGuaranteedNoWrapRegion to work on ranges
This will be used in a later patch to ScalarEvolution.  Right now only
the unit tests exercise the newly added code.

llvm-svn: 262637
2016-03-03 18:31:16 +00:00
Philip Reames
b6c3452142 [ConstantRange] Add umin/smin operators
This was split off from http://reviews.llvm.org/D17184.

Reviewed by: Sanjoy

llvm-svn: 262080
2016-02-26 22:08:18 +00:00
Sanjoy Das
47bea86903 [ConstantRange] Rename a method and add more doc
Rename makeNoWrapRegion to a more obvious makeGuaranteedNoWrapRegion,
and add a comment about the counter-intuitive aspects of the function.
This is to help prevent cases like PR26628.

llvm-svn: 261532
2016-02-22 16:13:02 +00:00
Yaron Keren
d008c8f557 Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment.
clang part in r259232, this is the LLVM part of the patch.

llvm-svn: 259240
2016-01-29 20:50:44 +00:00
Sanjoy Das
e4442f028b [IR] Add a makeNoWrapRegion method to ConstantRange
Summary: This will be used in a future change to ScalarEvolution.

Reviewers: hfinkel, reames, nlewycky

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13612

llvm-svn: 250975
2015-10-22 03:12:57 +00:00
Sanjoy Das
1f60e8293a [ConstantRange] Split makeICmpRegion in two.
Summary:
This change splits `makeICmpRegion` into `makeAllowedICmpRegion` and
`makeSatisfyingICmpRegion` with slightly different contracts.  The first
one is useful for determining what values some expression //may// take,
given that a certain `icmp` evaluates to true.  The second one is useful
for determining what values are guaranteed to //satisfy// a given
`icmp`.

Reviewers: nlewycky

Reviewed By: nlewycky

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8345

llvm-svn: 232575
2015-03-18 00:41:24 +00:00
James Molloy
297c2a24c8 [ConstantRange] Teach multiply to be cleverer about signed ranges.
Multiplication is not dependent on signedness, so just treating
all input ranges as unsigned is not incorrect. However it will cause
overly pessimistic ranges (such as full-set) when used with signed
negative values.

Teach multiply to try to interpret its inputs as both signed and
unsigned, and then to take the most specific (smallest population)
as its result.

llvm-svn: 231483
2015-03-06 15:50:47 +00:00
Chandler Carruth
436597fe00 [Modules] Move the ConstantRange class into the IR library. This is
a bit surprising, as the class is almost entirely abstracted away from
any particular IR, however it encodes the comparsion predicates which
mutate ranges as ICmp predicate codes. This is reasonable as they're
used for both instructions and constants. Thus, it belongs in the IR
library with instructions and constants.

llvm-svn: 202838
2014-03-04 12:24:34 +00:00