9313 Commits

Author SHA1 Message Date
Davide Italiano
2037eb7f15 [SCCP] Teach the pass how to handle div with overdefined operands.
This can prove that:

extern int f;
int g() {
    int x = 0;
    for (int i = 0; i < 365; ++i) {
        x /= f;
    }
    return x;
}

always returns zero. Thanks to Sanjoy for confirming this
transformation actually made sense (bugs are mine).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292531 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 23:07:51 +00:00
Haicheng Wu
7fee81b86c Revert "[InlineCost] Use TTI to check if GEP is free."
This reverts commit r292526.  The test case has problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292529 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 22:51:03 +00:00
Haicheng Wu
363cf03aa6 [InlineCost] Use TTI to check if GEP is free.
Currently, a GEP is considered free only if its indices are all constant.
TTI::getGEPCost() can give target-specific more accurate analysis. TTI is
already used for the cost of many other instructions.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292526 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 22:28:34 +00:00
Xin Tong
9e142cd03c Improve what can be promoted in LICM.
Summary:
In case of non-alloca pointers, we check for whether it is a pointer
from malloc-like calls and it is not captured. In such case, we can
promote the pointer, as the caller will have no way to access this pointer
even if there is unwinding in middle of the loop.

Reviewers: hfinkel, sanjoy, reames, eli.friedman

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292510 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 19:31:40 +00:00
Davide Italiano
02d80d355e [InstCombine] Simplify gep (gep p, a), (b-a)
Patch by Andrea Canciani.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292506 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 18:51:56 +00:00
Sanjay Patel
d942fa6726 [InstCombine] icmp Pred (shl nsw X, C1), C0 --> icmp Pred X, C0 >> C1
Try harder to fold icmp with shl nsw as discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2017-January/108749.html

This is similar to the 'shl nuw' transforms that were added with D25913.

This may eventually help solve:
https://llvm.org/bugs/show_bug.cgi?id=30773

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292492 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 16:12:10 +00:00
Peter Collingbourne
3a89c350b8 LowerTypeTests: Implement exporting of type identifiers.
Type identifiers are exported by:
- Adding coarse-grained information about how to test the type
  identifier to the summary.
- Creating symbols in the object file (aliases and absolute symbols)
  containing fine-grained information about the type identifier.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292462 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 01:20:11 +00:00
Michael Kuperstein
b9ac5dc04e [LV] Run loop-simplify and LCSSA explicitly instead of "requiring" them
This changes the vectorizer to explicitly use the loopsimplify and lcssa utils,
instead of "requiring" the transformations as if they were analyses.

This is not NFC, since it changes the LCSSA behavior - we no longer run LCSSA
for all loops, but rather only for the loops we expect to modify.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292456 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 00:42:28 +00:00
Sanjay Patel
4683557a5f [InstCombine] add tests for shl nsw with icmp eq/ne; NFCI
These should be fixed with D28406.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292441 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 21:31:21 +00:00
Peter Collingbourne
28f35758a5 ThinLTOBitcodeWriter: Clear comdats on filtered globals.
Differential Revision: https://reviews.llvm.org/D28839

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:03:02 +00:00
Michael Kuperstein
c3a226d450 [LV] Allow reductions that have several uses outside the loop
We currently check whether a reduction has a single outside user. We don't
really need to require that - we just need to make sure a single value is
used externally. The number of external users of that value shouldn't actually
matter.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292424 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 19:02:52 +00:00
Alexey Bataev
05153bfa17 [SLP] Add a tests for a fix for PR30787.
Add a test for PR30787: Failure to beneficially vectorize 'copyable'
elements in integer binary ops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292416 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 18:07:46 +00:00
Simon Pilgrim
c2e261218f [InstCombine][AVX2] Add DemandedElts support for VPERMD/VPERMPS shuffles
Simplify a vpermv shuffle mask based on the elements of the mask that are actually demanded.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292371 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 14:47:49 +00:00
Simon Pilgrim
e22dda95c0 [InstCombine][AVX2] Tests showing missed opportunities to pass demanded elts through a vpermd/vpermps shuffle
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292368 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 14:23:06 +00:00
Chandler Carruth
02f541f2f5 [PM] Teach LoopDeletion to correctly update the LPM when loops are
deleted.

I've expanded its test coverage a bit including adding one test that
will crash clearly without this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292332 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 02:41:26 +00:00
Chandler Carruth
abe496771f [LoopDeletion] (cleanup, NFC) Make this test actually test what it
claims to test.

LoopSimplify was unifying the multiple exits in this test case, making
it never even test the multiple exit handling of LoopDeletion. Doh.

Now it works (thanks to a great idea from mkuper) and will fail if we
ever change something to make it stop working.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292331 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 02:29:35 +00:00
Xin Tong
9d29b66e65 2 returns next to each other =). NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292315 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 00:26:17 +00:00
Sanjay Patel
bf51c92663 [InstCombine] add tests to show missed shrinkage; NFC
A patch to partially solve this:
https://reviews.llvm.org/D28625


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292296 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 00:03:23 +00:00
Dehao Chen
f519872cb6 Introduce -unroll-partial-threshold to separate PartialThreshold from Threshold in loop unorller.
Summary: Partial unrolling should have separate threshold with full unrolling.

Reviewers: efriedma, mzolotukhin

Reviewed By: efriedma, mzolotukhin

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292293 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 23:39:33 +00:00
Matthew Simpson
1b2cd634db [LV] Add requires asserts to test case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292280 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 22:21:33 +00:00
Xin Tong
985d6ae2d4 Add a test case for LICM when promoting locals that may be read after the throw within the loop. NFCI.
Summary: Add a test case for LICM when promoting locals that may be read after the throw within the loop.

Reviewers: eli.friedman, hfinkel, sanjoy

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292261 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 21:26:36 +00:00
Matthew Simpson
caab3a817f [LV] Mark non-consecutive-like pointers non-uniform
If a memory instruction will be vectorized, but it's pointer operand is
non-consecutive-like, the instruction is a gather or scatter operation. Its
pointer operand will be non-uniform. This should fix PR31671.

Reference: https://llvm.org/bugs/show_bug.cgi?id=31671
Differential Revision: https://reviews.llvm.org/D28819

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292254 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 20:51:39 +00:00
Xin Tong
ecf1f1111b Rename scalar_promote.ll to scalar-promote.ll and scalar_promote-unwind.ll to scalar-promote-unwind.ll. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292251 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 20:28:36 +00:00
Sanjoy Das
90b7e38b05 [EarlyCSE] Don't DSE across readnone functions that may throw
Summary: Depends on D28740

Reviewers: dberlin, chandlerc, hfinkel, majnemer

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292249 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 20:15:47 +00:00
Sanjay Patel
e9d3b46a1d [InstCombine] add tests for shl nsw + icmp sle; NFC
We want to handle these cases similarly to icmp sgt, so add the tests for it.
See: https://reviews.llvm.org/D28406


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292248 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 20:15:26 +00:00
Chandler Carruth
1c28b57b8b [PM] Teach the LoopPassManager to automatically canonicalize loops by
runnig LCSSA over them prior to running the loop pipeline.

This also teaches the loop PM to verify that LCSSA form is preserved
throughout the pipeline's run across the loop nest.

Most of the test updates just leverage this new functionality. One has to be
relaxed with the new PM as IVUsers is less powerful when it sees LCSSA input.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292241 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 19:18:12 +00:00
Sanjay Patel
3ecd20b357 [ValueTracking] recognize a 'not' of an assumed condition as false
Also, add the corresponding match to the AssumptionCache's 'Affected Values' list.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292239 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 18:15:49 +00:00
David Majnemer
64f84982ee [InstCombine] Fold ((C1 OP zext(X)) & C2) -> zext((C1 OP X) & C2)
This further extends r292179 to support additional binary operators
beyond subtraction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292238 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 18:08:06 +00:00
Chad Rosier
7eb6751ff6 [ValueTracking] Extend known bits to understand @llvm.bitreverse.
Differential Revision: https://reviews.llvm.org/D28780

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292233 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 17:23:51 +00:00
Simon Pilgrim
04f56107c5 [InstCombine][X86][AVX] Add DemandedElts support for VPERMILPD/VPERMILPS instructions
Simplify a vpermilvar shuffle mask based on the elements of the mask that are actually demanded.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292209 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 11:35:03 +00:00
Sanjoy Das
4b48551490 [InstCombine] Don't DSE across readnone functions that may throw
Summary: Depends on D28740

Reviewers: dberlin, chandlerc, hfinkel, majnemer

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292197 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 05:45:09 +00:00
David Majnemer
4b66daa8cc [InstCombine] Fold ((C1-zext(X)) & C2) -> zext((C1-X) & C2)
This is valid if C2 fits within the bitwidth of X thanks to two's
complement modulo arithmetic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292179 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 00:45:57 +00:00
Matt Arsenault
3802a656d3 Add comment to test file I forgot to save
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292178 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 00:35:28 +00:00
Matt Arsenault
3bd79e8a80 SimplifyLibCalls: Remove checks for fabs
Use the intrinsic instead of emitting the libcall which
will be replaced by the intrinsic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292176 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 00:30:31 +00:00
Matt Arsenault
5276f9a934 SimplifyLibCalls: Replace fabs libcalls with intrinsics
Add missing fabs(fpext) optimzation that worked with the call,
and also fixes it creating a second fpext when there were multiple
uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292172 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 00:10:40 +00:00
Simon Pilgrim
663d71421c [InstCombine][AVX] Tests showing missed opportunities to pass demanded elts through a permilpd/permilps shuffle mask
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292165 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 21:34:22 +00:00
Sanjay Patel
2222ec4bc9 [InstCombine] use m_APInt to allow shift-shift folds for vectors with splat constants
Some existing 'FIXME' tests are still not folded because of splat holes in value tracking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292151 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 19:35:45 +00:00
Sanjay Patel
63bb8f30ce [InstCombine] add tests to show missed vector folds; NFC
The shift-shift possibilities became easier to see after:
https://reviews.llvm.org/rL292145



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292150 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 19:23:34 +00:00
Simon Pilgrim
50d76a80ed [InstCombine][SSE] Tests showing missed opportunities to pass demanded elts through a packss/packus truncation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292144 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 17:26:23 +00:00
Simon Pilgrim
07d3c0f01c [InstCombine][SSE] Add DemandedElts support for PSHUFB instructions
Simplify a pshufb shuffle mask based on the elements of the mask that are actually demanded.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292101 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 11:30:41 +00:00
Sanjay Patel
5ec1d71357 [InstCombine] add tests to show missed vector folds; NFC
Also, add comments and remove bogus comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292082 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 23:45:03 +00:00
Simon Pilgrim
4354d8859a [InstCombine][SSE] Tests showing missed opportunities to pass demanded elts through a pshufb shuffle mask
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292072 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 17:49:04 +00:00
Sanjay Patel
f6be6abb81 [InstCombine] use m_APInt to allow ashr folds for vectors with splat constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292064 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 16:38:19 +00:00
Sanjay Patel
b41dc00dd6 [InstCombine] add explanatory comments to tests; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292063 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 16:22:26 +00:00
Chandler Carruth
0e327f2e11 [PM] Clean up the testing for IVUsers, especially with the new PM.
First, I've moved a test of IVUsers from the LSR tree to a dedicated
IVUsers test directory. I've also simplified its RUN line now that the
new pass manager's loop PM is providing analyses on their own.

No functionality changed, but it makes subsequent changes cleaner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292060 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 09:29:27 +00:00
Chandler Carruth
340ad683c8 [PM] Fix instcombine's analysis preservation in the new pass manager to
cover domtree and alias analysis. These are the pretty clear analyses
that we would always want to survive this pass.

To make these survive, we also need to preserve the assumption cache.

Added a test that verifies the important bits of this preservation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292037 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-14 23:25:22 +00:00
Sanjay Patel
1849414f3e [InstCombine] add test to show missed vector fold; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292035 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-14 23:12:29 +00:00
Daniel Berlin
ea4e23e5be NewGVN: Fix PR31613 test regex naming
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291979 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 23:54:10 +00:00
Sanjay Patel
3d039197d7 [InstCombine] optimize unsigned icmp of increment
Allows LLVM to optimize sequences like the following:

%add = add nuw i32 %x, 1
%cmp = icmp ugt i32 %add, %y

Into:

%cmp = icmp uge i32 %x, %y

Previously, only signed comparisons were being handled.

Decrements could also be handled, but 'sub nuw %x, 1' is currently canonicalized to
'add %x, -1' in InstCombineAddSub, losing the nuw flag. Removing that canonicalization
seems like it might have far-reaching ramifications so I kept this simple for now.

Patch by Matti Niemenmaa!

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291975 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 23:25:46 +00:00
Sanjay Patel
534e635d1b [InstCombine] use m_APInt to allow lshr folds for vectors with splat constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291972 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 23:04:10 +00:00