Commit Graph

8607 Commits

Author SHA1 Message Date
Sanjay Patel
a690e12aba [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat constant vectors, part 4
This concludes the fixes for icmp+shl in this series:
https://reviews.llvm.org/rL279339
https://reviews.llvm.org/rL279398
https://reviews.llvm.org/rL279399



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279401 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-21 17:10:07 +00:00
Sanjay Patel
207248202b remove FIXME comment; fixed by previous commit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279400 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-21 16:40:42 +00:00
Sanjay Patel
ecce337063 [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat constant vectors, part 3
This is a partial enablement (move the ConstantInt guard down).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279399 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-21 16:35:34 +00:00
Sanjay Patel
a5d876194d [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat constant vectors, part 2
This is a partial enablement (move the ConstantInt guard down).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279398 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-21 16:28:22 +00:00
Matthew Simpson
fcc016a4ea Reapply "[SLP] Initialize VectorizedValue when gathering"
The test case included in r279125 exposed existing undefined behavior in the
SLP vectorizer that it did not introduce. This patch reapplies the original
patch, but modifies the test case to avoid hitting the undefined behavior. This
allows us to close PR28330 while keeping the UBSan bot happy. The undefined
behavior the original test uncovered will be addressed in a follow-on patch.

Reference: https://llvm.org/bugs/show_bug.cgi?id=28330

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279370 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-20 14:49:02 +00:00
Vitaly Buka
914b867b4c Revert "[SLP] Initialize VectorizedValue when gathering" to fix ubsan bot.
This reverts commit r279125.

https://reviews.llvm.org/D23410

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-20 07:09:39 +00:00
Xinliang David Li
990c9c02c4 [Profile] add test with large counts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279361 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-20 05:28:42 +00:00
Sanjay Patel
177fbef1aa [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat constant vectors, part 1
This is a partial enablement (move the ConstantInt guard down) because there are many
different folds here and one of the later ones will require reworking 'isSignBitCheck'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279339 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 22:33:26 +00:00
Reid Kleckner
b89c2fc4a9 Revert "[SimplifyCFG] Rewrite SinkThenElseCodeToEnd"
This reverts commit r279229. It breaks intrinsic function calls in
diamonds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279313 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 20:22:39 +00:00
Reid Kleckner
baeb19c0b9 Fix regression in InstCombine introduced by r278944
The intended transform is:
  // Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0
  // -> and (icmp eq P, null), (icmp eq Q, null).

P and Q are both pointer types, but may have different types. We need
two calls to getNullValue() to make the icmps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279271 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 16:53:18 +00:00
David Majnemer
c00499c663 [CloneFunction] Don't remove unrelated nodes from the CGSSC
CGSCC use a WeakVH to track call sites.  RAUW a call within a function
can result in that WeakVH getting confused about whether or not the call
site is still around.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279268 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 16:37:40 +00:00
Sanjay Patel
1238f8d56b [InstCombine] use m_APInt to allow icmp (shl 1, Y), C folds for splat constant vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279266 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 16:12:16 +00:00
Sanjay Patel
ee783de739 [InstCombine] use m_APInt to allow icmp X, C folds for splat constant vectors
Of course, we really need to refactor and fix all of the cmp predicates, 
but this one is interesting because without it, we later perform an 
information-losing transform of icmp (shl 1, Y), C, and we can't recover
the better fold.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279263 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 15:40:44 +00:00
Sanjay Patel
f17d15a58d [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279259 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 15:27:28 +00:00
Sanjay Patel
762d2ecc14 [InstCombine] add missing tests for basic icmp folds
These are implicitly included as part of larger test cases, but they don't 
exist stand-alone (and don't happen for vectors...).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279257 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 15:21:45 +00:00
James Molloy
028b488adc [SimplifyCFG] Rewrite SinkThenElseCodeToEnd
The new version has several advantages:
  1) IMSHO it's more readable and neater
  2) It handles loads and stores properly
  3) It can handle any number of incoming blocks rather than just two. I'll be taking advantage of this in a followup patch.

With this change we can now finally sink load-modify-store idioms such as:

    if (a)
      return *b += 3;
    else
      return *b += 4;

    =>

    %z = load i32, i32* %y
    %.sink = select i1 %a, i32 5, i32 7
    %b = add i32 %z, %.sink
    store i32 %b, i32* %y
    ret i32 %b

When this works for switches it'll be even more powerful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279229 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 10:10:27 +00:00
Amaury Sechet
c43ec38718 Make cltz and cttz zero undef when the operand cannot be zero in InstCombine
Summary: Also add popcount(n) == bitsize(n)  -> n == -1 transformation.

Reviewers: majnemer, spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279141 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 20:43:50 +00:00
Sanjay Patel
d87f299ea2 [InstCombine] use m_APInt to allow icmp (trunc X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935
https://reviews.llvm.org/rL278945
https://reviews.llvm.org/rL279066
https://reviews.llvm.org/rL279077
https://reviews.llvm.org/rL279101


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279133 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 20:28:54 +00:00
Matthew Simpson
3989d7e56d [SLP] Initialize VectorizedValue when gathering
We abort building vectorizable trees in some cases (e.g., if the maximum
recursion depth is reached, if the region size is too large, etc.). If this
happens for a reduction, we can be left with a root entry that needs to be
gathered. For these cases, we need make sure we actually set VectorizedValue to
the resulting vector.

This patch ensures we properly set VectorizedValue, and it also ensures the
insertelement sequence generated for the gathers is inserted at the correct
location.

Reference: https://llvm.org/bugs/show_bug.cgi?id=28330
Differential Revison: https://reviews.llvm.org/D23410

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279125 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 19:50:32 +00:00
Sanjay Patel
030db6490a [InstCombine] use m_APInt to allow icmp (udiv X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935
https://reviews.llvm.org/rL278945
https://reviews.llvm.org/rL279066
https://reviews.llvm.org/rL279077


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279101 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 17:55:59 +00:00
Artur Pilipenko
2e26f159da CVP. Turn marking adds as no wrap (introduced by r278107) off by default
It causes a regression on our internal benchmark. Introduce cvp-dont-process flag and set it off by default while investigating the regression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279082 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 16:08:35 +00:00
Sanjay Patel
1759316b11 [InstCombine] use m_APInt to allow icmp (mul X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935
https://reviews.llvm.org/rL278945
https://reviews.llvm.org/rL279066



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279077 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 15:44:44 +00:00
Sanjay Patel
94dd772827 [InstCombine] use m_APInt to allow icmp (xor X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935
https://reviews.llvm.org/rL278945


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279066 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 14:10:48 +00:00
Chad Rosier
c73cfcfe02 [Reassociate] Add test for PR28367.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279063 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 13:22:37 +00:00
Sanjay Patel
1a5ebc4b9d [InstCombine] add test for missing vector icmp fold
Also, add a scalar test to demonstrate one of the intermediate folds that
is necessary to accomplish the existing, multi-step test. And simplify
the vector tests to only check the final piece of that multi-step transform.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278995 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 22:18:57 +00:00
Sanjay Patel
6eaa7d5317 [InstCombine] minimize tests and autogenerate checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278960 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 19:56:10 +00:00
Sanjay Patel
9df37461f6 [InstCombine] use m_APInt to allow icmp (or X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 16:38:57 +00:00
Sanjay Patel
9bec09deff [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 16:23:15 +00:00
Chad Rosier
a537a2bbfe Revert "Reassociate: Reprocess RedoInsts after each inst".
This reverts commit r258830, which introduced a bug described in PR28367.

PR28367

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278938 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 15:54:39 +00:00
Sanjay Patel
3b03767801 [InstCombine] use m_APInt to allow icmp (add X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278935 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 15:24:30 +00:00
Chad Rosier
cab764a320 Revert "[Reassociate] Avoid iterator invalidation when negating value."
This reverts commit r278928 due to lit test failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278929 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 14:31:34 +00:00
Chad Rosier
291f9294da [Reassociate] Avoid iterator invalidation when negating value.
Differential Revision: https://reviews.llvm.org/D23464
PR28367

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278928 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 14:16:45 +00:00
Chandler Carruth
b699f7b88f [PM] Port the always inliner to the new pass manager in a much more
minimal and boring form than the old pass manager's version.

This pass does the very minimal amount of work necessary to inline
functions declared as always-inline. It doesn't support a wide array of
things that the legacy pass manager did support, but is alse ... about
20 lines of code. So it has that going for it. Notably things this
doesn't support:

- Array alloca merging
  - To support the above, bottom-up inlining with careful history
    tracking and call graph updates
- DCE of the functions that become dead after this inlining.
- Inlining through call instructions with the always_inline attribute.
  Instead, it focuses on inlining functions with that attribute.

The first I've omitted because I'm hoping to just turn it off for the
primary pass manager. If that doesn't pan out, I can add it here but it
will be reasonably expensive to do so.

The second should really be handled by running global-dce after the
inliner. I don't want to re-implement the non-trivial logic necessary to
do comdat-correct DCE of functions. This means the -O0 pipeline will
have to be at least 'always-inline,global-dce', but that seems
reasonable to me. If others are seriously worried about this I'd like to
hear about it and understand why. Again, this is all solveable by
factoring that logic into a utility and calling it here, but I'd like to
wait to do that until there is a clear reason why the existing
pass-based factoring won't work.

The final point is a serious one. I can fairly easily add support for
this, but it seems both costly and a confusing construct for the use
case of the always inliner running at -O0. This attribute can of course
still impact the normal inliner easily (although I find that
a questionable re-use of the same attribute). I've started a discussion
to sort out what semantics we want here and based on that can figure out
if it makes sense ta have this complexity at O0 or not.

One other advantage of this design is that it should be quite a bit
faster due to checking for whether the function is a viable candidate
for inlining exactly once per function instead of doing it for each call
site.

Anyways, hopefully a reasonable starting point for this pass.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278896 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 02:56:20 +00:00
Sanjay Patel
96f8a5707a [InstCombine] add tests for fold with no coverage and missing vector fold
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278867 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 23:18:42 +00:00
Sanjay Patel
764b87be23 [InstCombine] use m_APInt to allow icmp (sub X, Y), C folds for splat constant vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278859 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 21:53:19 +00:00
David Majnemer
662809578e Make MDNode::intersect faster than O(n * m)
It is pretty easy to get it down to O(nlogn + mlogm).  This
implementation has the added benefit of automatically deduplicating
entries between the two sets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278837 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 18:48:37 +00:00
David Majnemer
9c509583cc Don't passively concatenate MDNodes
I have audited all the callers of concatenate and none require duplicate
entries to service concatenation.
These duplicates serve no purpose but to needlessly embiggen the IR.

N.B. Layering getMostGenericAliasScope on top of concatenate makes it
O(nlogn + mlogm) instead of O(n*m).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278836 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 18:48:34 +00:00
Gor Nishanov
6795b93241 [Coroutines] Part 7: Split coroutine into subfunctions
Summary:
This patch adds simple coroutine splitting logic to CoroSplit pass.

Documentation and overview is here: http://llvm.org/docs/Coroutines.html.

Upstreaming sequence (rough plan)
1.Add documentation. (https://reviews.llvm.org/D22603)
2.Add coroutine intrinsics. (https://reviews.llvm.org/D22659)
...
7. Split coroutine into subfunctions <= we are here
8. Coroutine Frame Building algorithm
9. Handle coroutine with unwinds
10+. The rest of the logic

Reviewers: majnemer

Subscribers: llvm-commits, mehdi_amini

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278830 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 18:04:14 +00:00
David Majnemer
0bf24e0333 [InstSimplify] Fold gep (gep V, C), (xor V, -1) to C-1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278779 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 06:13:46 +00:00
Sanjay Patel
8454221022 [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278768 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 00:48:38 +00:00
Sanjay Patel
8e443cd8d1 [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278765 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 00:27:12 +00:00
Sanjay Patel
dfacb43d50 [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278757 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 22:43:52 +00:00
Sanjay Patel
caa310554b [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278751 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 21:47:50 +00:00
Sanjay Patel
72159afddb [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 21:37:24 +00:00
Sanjay Patel
70fd49b5bf update tests to use FileCheck and exact checking
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 21:02:25 +00:00
Sanjay Patel
f9b2472517 [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278737 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 20:56:11 +00:00
Sanjay Patel
fa85d67d36 [InstCombine] add test for missing vector icmp fold
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 20:02:40 +00:00
Sanjay Patel
f7714c1cd1 [InstCombine] add tests for vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278726 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 19:58:21 +00:00
Sanjay Patel
7016f855b3 [InstCombine] add tests for missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 19:16:33 +00:00
Sanjay Patel
bb8ab1ab78 update test to use FileCheck and autogenerated checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278714 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 18:56:10 +00:00