Nikita Popov
9d9633fb70
[CVP] Simplify cmp of local phi node
...
CVP currently does not simplify cmps with instructions in the same
block, because LVI getPredicateAt() currently does not provide
much useful information for that case (D69686 would change that,
but is stuck.) However, if the instruction is a Phi node, then
LVI can compute the result of the predicate by threading it into
the predecessor blocks, which allows it simplify some conditions
that nothing else can handle. Relevant code:
6d6a4590c5/llvm/lib/Analysis/LazyValueInfo.cpp (L1904-L1927)
Differential Revision: https://reviews.llvm.org/D72169
2020-02-26 20:36:41 +01:00
Nikita Popov
3e440545dc
[CVP] Add test for cmp of local phi; NFC
2020-02-26 20:32:59 +01:00
Roman Lebedev
69ce2ae990
[ConstantRange][LVI] Use overflow flags from `sub` to constrain the range
...
Summary:
This notably improves non-negativity deduction:
```
| statistic | old | new | delta | % change |
| correlated-value-propagation.NumAShrs | 209 | 227 | 18 | 8.6124% |
| correlated-value-propagation.NumAddNSW | 4972 | 4988 | 16 | 0.3218% |
| correlated-value-propagation.NumAddNUW | 7141 | 7148 | 7 | 0.0980% |
| correlated-value-propagation.NumAddNW | 12113 | 12136 | 23 | 0.1899% |
| correlated-value-propagation.NumAnd | 442 | 445 | 3 | 0.6787% |
| correlated-value-propagation.NumNSW | 7160 | 7176 | 16 | 0.2235% |
| correlated-value-propagation.NumNUW | 13306 | 13316 | 10 | 0.0752% |
| correlated-value-propagation.NumNW | 20466 | 20492 | 26 | 0.1270% |
| correlated-value-propagation.NumSDivs | 207 | 212 | 5 | 2.4155% |
| correlated-value-propagation.NumSExt | 6279 | 6679 | 400 | 6.3704% |
| correlated-value-propagation.NumSRems | 28 | 29 | 1 | 3.5714% |
| correlated-value-propagation.NumShlNUW | 2793 | 2796 | 3 | 0.1074% |
| correlated-value-propagation.NumShlNW | 3964 | 3967 | 3 | 0.0757% |
| correlated-value-propagation.NumUDivs | 353 | 358 | 5 | 1.4164% |
| instcount.NumAShrInst | 13763 | 13741 | -22 | -0.1598% |
| instcount.NumAddInst | 277349 | 277348 | -1 | -0.0004% |
| instcount.NumLShrInst | 27437 | 27463 | 26 | 0.0948% |
| instcount.NumOrInst | 102677 | 102678 | 1 | 0.0010% |
| instcount.NumSDivInst | 8732 | 8727 | -5 | -0.0573% |
| instcount.NumSExtInst | 80872 | 80468 | -404 | -0.4996% |
| instcount.NumSRemInst | 1679 | 1678 | -1 | -0.0596% |
| instcount.NumTruncInst | 62154 | 62153 | -1 | -0.0016% |
| instcount.NumUDivInst | 2526 | 2527 | 1 | 0.0396% |
| instcount.NumURemInst | 1589 | 1590 | 1 | 0.0629% |
| instcount.NumZExtInst | 69405 | 69809 | 404 | 0.5821% |
| instcount.TotalInsts | 7439575 | 7439574 | -1 | 0.0000% |
```
Reviewers: nikic, reames, spatel
Reviewed By: nikic
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69942
2019-11-07 16:18:03 +03:00
Roman Lebedev
55b445150d
[NFC][CVP] Add some tests for `sub` with preexisting no-wrap flags
...
We can use those to further limit the ranges in LVI.
2019-11-07 13:59:51 +03:00
Nikita Popov
98245d081e
[JT][CVP] Regenerate test checks, again
...
The changes to update_test_checks format have been disabled again,
so regenerate these tests. Also regenerate select.ll.
2019-11-01 22:27:48 +01:00
Nikita Popov
2f8a43e199
[CVP] Add tests for icmp on local ranges; NFC
...
We currently don't simplify these, because getPredicateAt() does
not use block values.
2019-10-31 22:24:46 +01:00
Roman Lebedev
1f665046fb
[LVI][CVP] LazyValueInfoImpl::solveBlockValueBinaryOp(): use no-wrap flags from `add` op
...
Summary:
This was suggested in https://reviews.llvm.org/D69277#1717210
In this form (this is what was suggested, right?), the results aren't staggering
(especially since given LVI cross-block focus)
this does catch some things (as per test-suite), but not too much:
| statistic | old | new | delta | % change |
| correlated-value-propagation.NumAddNSW | 4981 | 4982 | 1 | 0.0201% |
| correlated-value-propagation.NumAddNW | 12125 | 12126 | 1 | 0.0082% |
| correlated-value-propagation.NumCmps | 1199 | 1202 | 3 | 0.2502% |
| correlated-value-propagation.NumDeadCases | 112 | 111 | -1 | -0.8929% |
| correlated-value-propagation.NumMulNSW | 275 | 278 | 3 | 1.0909% |
| correlated-value-propagation.NumMulNUW | 1323 | 1326 | 3 | 0.2268% |
| correlated-value-propagation.NumMulNW | 1598 | 1604 | 6 | 0.3755% |
| correlated-value-propagation.NumNSW | 7158 | 7167 | 9 | 0.1257% |
| correlated-value-propagation.NumNUW | 13304 | 13310 | 6 | 0.0451% |
| correlated-value-propagation.NumNW | 20462 | 20477 | 15 | 0.0733% |
| correlated-value-propagation.NumOverflows | 4 | 7 | 3 | 75.0000% |
| correlated-value-propagation.NumPhis | 15366 | 15381 | 15 | 0.0976% |
| correlated-value-propagation.NumSExt | 6273 | 6277 | 4 | 0.0638% |
| correlated-value-propagation.NumShlNSW | 1172 | 1171 | -1 | -0.0853% |
| correlated-value-propagation.NumShlNUW | 2793 | 2794 | 1 | 0.0358% |
| correlated-value-propagation.NumSubNSW | 730 | 736 | 6 | 0.8219% |
| correlated-value-propagation.NumSubNUW | 2044 | 2046 | 2 | 0.0978% |
| correlated-value-propagation.NumSubNW | 2774 | 2782 | 8 | 0.2884% |
| instcount.NumAddInst | 277586 | 277569 | -17 | -0.0061% |
| instcount.NumAndInst | 66056 | 66054 | -2 | -0.0030% |
| instcount.NumBrInst | 709147 | 709146 | -1 | -0.0001% |
| instcount.NumCallInst | 528579 | 528576 | -3 | -0.0006% |
| instcount.NumExtractValueInst | 18307 | 18301 | -6 | -0.0328% |
| instcount.NumOrInst | 102660 | 102665 | 5 | 0.0049% |
| instcount.NumPHIInst | 318008 | 318007 | -1 | -0.0003% |
| instcount.NumSelectInst | 46373 | 46370 | -3 | -0.0065% |
| instcount.NumSExtInst | 79496 | 79488 | -8 | -0.0101% |
| instcount.NumShlInst | 40654 | 40657 | 3 | 0.0074% |
| instcount.NumTruncInst | 62251 | 62249 | -2 | -0.0032% |
| instcount.NumZExtInst | 68211 | 68221 | 10 | 0.0147% |
| instcount.TotalBlocks | 843910 | 843909 | -1 | -0.0001% |
| instcount.TotalInsts | 7387448 | 7387423 | -25 | -0.0003% |
Reviewers: nikic, reames
Reviewed By: nikic
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69321
2019-10-23 18:17:32 +03:00
Roman Lebedev
9b1419a9e5
[NFC][LVI][CVP] Tests where pre-specified `add` no-wrap flags could be used by LVI
...
There's `ConstantRange::addWithNoWrap()`, LVI could use it to further
constrain the range, if an `add` already has some no-wrap flags specified.
2019-10-22 22:54:57 +03:00
Roman Lebedev
7cd7f4a83b
[CVP] No-wrap deduction for `shl`
...
Summary:
This is the last `OverflowingBinaryOperator` for which we don't deduce flags.
D69217 taught `ConstantRange::makeGuaranteedNoWrapRegion()` about it.
The effect is better than of the `mul` patch (D69203):
| statistic | old | new | delta | % change |
| correlated-value-propagation.NumAddNUW | 7145 | 7144 | -1 | -0.0140% |
| correlated-value-propagation.NumAddNW | 12126 | 12125 | -1 | -0.0082% |
| correlated-value-propagation.NumAnd | 443 | 446 | 3 | 0.6772% |
| correlated-value-propagation.NumNSW | 5986 | 7158 | 1172 | 19.5790% |
| correlated-value-propagation.NumNUW | 10512 | 13304 | 2792 | 26.5601% |
| correlated-value-propagation.NumNW | 16498 | 20462 | 3964 | 24.0272% |
| correlated-value-propagation.NumShlNSW | 0 | 1172 | 1172 | |
| correlated-value-propagation.NumShlNUW | 0 | 2793 | 2793 | |
| correlated-value-propagation.NumShlNW | 0 | 3965 | 3965 | |
| instcount.NumAShrInst | 13824 | 13790 | -34 | -0.2459% |
| instcount.NumAddInst | 277584 | 277586 | 2 | 0.0007% |
| instcount.NumAndInst | 66061 | 66056 | -5 | -0.0076% |
| instcount.NumBrInst | 709153 | 709147 | -6 | -0.0008% |
| instcount.NumICmpInst | 483709 | 483708 | -1 | -0.0002% |
| instcount.NumSExtInst | 79497 | 79496 | -1 | -0.0013% |
| instcount.NumShlInst | 40691 | 40654 | -37 | -0.0909% |
| instcount.NumSubInst | 61997 | 61996 | -1 | -0.0016% |
| instcount.NumZExtInst | 68208 | 68211 | 3 | 0.0044% |
| instcount.TotalBlocks | 843916 | 843910 | -6 | -0.0007% |
| instcount.TotalInsts | 7387528 | 7387448 | -80 | -0.0011% |
Reviewers: nikic, reames, sanjoy, timshen
Reviewed By: nikic
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69277
llvm-svn: 375455
2019-10-21 21:31:19 +00:00
Nikita Popov
f1ffc4305d
[CVP] Reenable nowrap flag inference
...
Inference of nowrap flags in CVP has been disabled, because it
triggered a bug in LFTR (https://bugs.llvm.org/show_bug.cgi?id=31181 ).
This issue has been fixed in D60935, so we should be able to reenable
nowrap flag inference now.
Differential Revision: https://reviews.llvm.org/D62776
llvm-svn: 364228
2019-06-24 20:13:13 +00:00
Eric Christopher
cee313d288
Revert "Temporarily Revert "Add basic loop fusion pass.""
...
The reversion apparently deleted the test/Transforms directory.
Will be re-reverting again.
llvm-svn: 358552
2019-04-17 04:52:47 +00:00
Eric Christopher
a863435128
Temporarily Revert "Add basic loop fusion pass."
...
As it's causing some bot failures (and per request from kbarton).
This reverts commit r358543/ab70da07286e618016e78247e4a24fcb84077fda.
llvm-svn: 358546
2019-04-17 02:12:23 +00:00
Sanjay Patel
83d1d3f167
[CVP] auto-generate complete test checks; NFC
...
llvm-svn: 347866
2018-11-29 14:28:47 +00:00
John Regehr
3a1c9d55cc
[LVI] run transfer function for binary operator even when the RHS isn't a constant
...
LVI was symbolically executing binary operators only when the RHS was
constant, missing the case where we have a ConstantRange for the RHS,
but not an actual constant. Tested using check-all and by
bootstrapping. Compile time is not impacted measurably.
Differential Revision: https://reviews.llvm.org/D19859
llvm-svn: 347379
2018-11-21 05:24:12 +00:00
Sean Silva
b025d375a1
[PM] Port CorrelatedValuePropagation
...
llvm-svn: 274705
2016-07-06 23:26:29 +00:00
Hans Wennborg
45172aceb3
LazyValueInfo: Actually re-visit partially solved block-values in solveBlockValue()
...
If solveBlockValue() needs results from predecessors that are not already
computed, it returns false with the intention of resuming when the dependencies
have been resolved. However, the computation would never be resumed since an
'overdefined' result had been placed in the cache, preventing any further
computation.
The point of placing the 'overdefined' result in the cache seems to have been
to break cycles, but we can check for that when inserting work items in the
BlockValue stack instead. This makes the "stop and resume" mechanism of
solveBlockValue() work as intended, unlocking more analysis.
Using this patch shaves 120 KB off a 64-bit Chromium build on Linux.
I benchmarked compiling bzip2.c at -O2 but couldn't measure any difference in
compile time.
Tests by Jiangning Liu from r215343 / PR21238, Pete Cooper, and me.
Differential Revision: http://reviews.llvm.org/D6397
llvm-svn: 222768
2014-11-25 17:23:05 +00:00