9331 Commits

Author SHA1 Message Date
Daniel Berlin
13b8e1fe24 NewGVN: Remove pr31686.ll, it is tested by pr31594.ll, which is much smaller and simpler
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292649 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 21:04:58 +00:00
Daniel Berlin
d130a4ccb6 NewGVN: Fix PR 31686 and PR 31698 by rewriting store leader handling.
Summary:

This rewrites store expression/leader handling.  We no longer use the
value operand as the leader, instead, we store it separately.  We also
now store the stored value as part of the expression, and compare it
when comparing stores for equality.  This enables us to get rid of a
bunch of our previous hacks and machinations, as the existing
machinery takes care of everything *except* updating the stored value
on classes.  The only time we have to update it is if the storecount
goes to 0, and when we do, we destroy it.

Since we no longer use the value operand as the leader, during elimination, we have to use the value operand.  Doing this also fixes a bunch of store forwarding cases we were missing.

Any value operand we use is guaranteed to either be updated by previous eliminations, or minimized by future ones.

(IE the fact that we don't use the most dominating value operand when it's not a constant does not affect anything).

Sadly, this change also exposes that we didn't pay attention to the
output of the pr31594.ll test, as it also very clearly exposes the
same store leader bug we are fixing here.

(I added pr31682.ll anyway, but maybe we think that's too large to be useful)

On the plus side, propagate-ir-flags.ll now passes due to the
corrected store forwarding.

This change was 3 stage'd on darwin and linux, with the full test-suite.

Reviewers:
davide
Subscribers:
llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292648 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 21:04:30 +00:00
Haicheng Wu
84ce155044 Recommit "[InlineCost] Use TTI to check if GEP is free." #3
This is the third attemp to recommit r292526.

The original summary:

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292633 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 18:51:22 +00:00
Alexey Bataev
27f0bb5af4 [SLP] Initial test for fix of PR31690.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 18:40:21 +00:00
Simon Pilgrim
116ba1a31a [InstCombine][X86] Add MULDQ/MULUDQ undef handling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292627 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 18:20:30 +00:00
Alexey Bataev
4a8de03c17 [SLP] A new test for horizontal vectorization for non-power-of-2
instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 18:04:29 +00:00
Simon Pilgrim
1d1dc060d7 [InstCombine][SSE] Tests showing missed opportunities to handle muldq/muludq with undef arguments
Fixed a typo in existing test names at the same time

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292619 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 17:06:38 +00:00
Haicheng Wu
d1af97c6c0 Revert "Recommit "[InlineCost] Use TTI to check if GEP is free." #2"
This reverts commit r292616 because the test case still has problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292618 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 16:52:22 +00:00
Haicheng Wu
bdcefb6024 Recommit "[InlineCost] Use TTI to check if GEP is free." #2
This is the second attemp to recommit r292526.

The original summary:

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292616 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 16:36:34 +00:00
Simon Pilgrim
4ad0fb1e2c [InstCombine][SSE] Tests showing missed opportunities to constant fold packss/packus
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292609 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 13:21:30 +00:00
Simon Pilgrim
0a1c1b20e2 [InstCombine][SSE] Tests showing missed opportunities to handle packss/packus with undef arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292601 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 11:28:07 +00:00
Simon Pilgrim
87735961e4 [InstCombine][SSE] Add DemandedElts support for PACKSS/PACKUS instructions
Simplify a packss/packus truncation based on the elements of the mask that are actually demanded.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292591 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 09:28:21 +00:00
Chandler Carruth
017c62c41d [PM] Port LoopSink to the new pass manager.
Like several other loop passes (the vectorizer, etc) this pass doesn't
really fit the model of a loop pass. The critical distinction is that it
isn't intended to be pipelined together with other loop passes. I plan
to add some documentation to the loop pass manager to make this more
clear on that side.

LoopSink is also different because it doesn't really need a lot of the
infrastructure of our loop passes. For example, if there aren't loop
invariant instructions causing a preheader to exist, there is no need to
form a preheader. It also doesn't need LCSSA because this pass is
only involved in sinking invariant instructions from a preheader into
the loop, not reasoning about live-outs.

This allows some nice simplifications to the pass in the new PM where we
can directly walk the loops once without restructuring them.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292589 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 08:42:19 +00:00
Daniel Berlin
a0431ff170 NewGVN: Fix PR 31682, an overactive assert.
Part of the assert has been left active for further debugging.
The other part has been turned into a stat for tracking for the
moment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292583 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 06:38:41 +00:00
Mohammad Shahid
b60e3766a8 [SLP] Add a base test for jumbled store
Change-Id: I905ce08a02c76a6896dcfd9629547417c99adc4a

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292581 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 06:05:33 +00:00
Haicheng Wu
035363ac91 Revert "Recommit "[InlineCost] Use TTI to check if GEP is free.""
This reverts commit r292570.  The test still has problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292572 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 03:40:41 +00:00
Haicheng Wu
9f9ec3cd24 Recommit "[InlineCost] Use TTI to check if GEP is free."
This recommits r292526 which is reverted in r292529 after fixing the test case.

The original summary:

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292570 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 03:09:11 +00:00
Anna Thomas
aaeaea1399 [AliasAnalysis] Fences do not modify constant memory location
Summary:
Fence instructions are currently marked as `ModRef` for all memory locations.

We can improve this for constant memory locations (such as constant globals),
since fence instructions cannot modify these locations.

This helps us to forward constant loads across fences (added test case in GVN).
There were no changes in behaviour for similar test cases in early-cse and licm.

Reviewers: dberlin, sanjoy, reames

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292546 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 00:21:33 +00:00
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