Commit Graph

8641 Commits

Author SHA1 Message Date
Sanjay Patel
f097e134b1 [InstCombine] replace divide-by-constant checks with asserts; NFC
These folds already have tests for scalar and vector types, except 
for the vector div-by-0 case, so I'm adding tests for that.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280115 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-30 17:31:34 +00:00
James Molloy
95bbd1e5dd [SimplifyCFG] Properly CSE metadata in SinkThenElseCodeToEnd
This was missing, meaning the metadata in sunk instructions was potentially bogus and could cause miscompiles.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-30 10:56:08 +00:00
Teresa Johnson
cf538716fb [ThinLTO] Indirect call promotion fixes for promoted local functions
Summary:
Fix a couple issues limiting the application of indirect call promotion
in ThinLTO mode:
- Invoke indirect call promotion before globalopt, since it may
  eliminate imported functions which appear unreferenced.
- Invoke indirect call promotion with InLTO=true so that the PGOFuncName
  metadata is used to get the name for locals which would have been
  renamed during promotion.

Reviewers: davidxl, mehdi_amini

Subscribers: Prazek, llvm-commits, mehdi_amini

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280024 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 22:46:56 +00:00
Matthew Simpson
1254de0c5c [LV] Move insertelement sequence after scalar definitions
After r279649 when getting a vector value from VectorLoopValueMap, we create an
insertelement sequence on-demand if the value has been scalarized instead of
vectorized. We previously inserted this insertelement sequence before the
value's first vector user. However, this insert location is problematic if that
user is the phi node of a first-order recurrence. With this patch, we move the
insertelement sequence after the last scalar instruction we created when
scalarizing the value. Thus, the value's vector definition in the new loop will
immediately follow its scalar definitions. This should fix PR30183.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280001 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 20:14:04 +00:00
David Majnemer
f94d4a796c [SimplifyCFG] Hoisting invalidates metadata
We forgot to remove optimization metadata when performing hosting during
FoldTwoEntryPHINode.

This fixes PR29163.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279980 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 17:14:08 +00:00
Anna Thomas
3262806b21 [StatepointsForGC] Rematerialize in the presence of PHIs
Summary:
While walking the use chain for identifying rematerializable values in RS4GC,
add the case where the current value and base value are the same PHI nodes.

This will aid rematerialization of geps and casts instead of relocating.

Reviewers: sanjoy, reames, igor

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279975 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 15:41:59 +00:00
Sanjay Patel
ae5557cf0a [Constant] remove fdiv and frem from canTrap()
Assuming the default FP env, we should not treat fdiv and frem any differently in terms of
trapping behavior than any other FP op. Ie, FP ops do not trap with the default FP env.

This matches how we treat the fdiv/frem in IR with isSafeToSpeculativelyExecute() and in 
the backend after:
https://reviews.llvm.org/rL279970



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279973 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 15:27:17 +00:00
Sanjay Patel
d00367231d [SimplifyCFG] rename test file, regenerate checks, and add test
The fdiv test shows a problem similar to:
https://reviews.llvm.org/rL279970


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279972 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 14:57:53 +00:00
Gor Nishanov
bce16c69f0 [Coroutines] Part 9: Add cleanup subfunction.
Summary:
[Coroutines] Part 9: Add cleanup subfunction.

This patch completes coroutine heap allocation elision. Now, the heap elision example from docs\Coroutines.rst compiles and produces expected result (see test/Transform/Coroutines/ex3.ll)

Intrinsic Changes:
* coro.free gets a token parameter tying it to coro.id to allow reliably discovering all coro.frees associated with a particular coroutine.
* coro.id gets an extra parameter that points back to a coroutine function. This allows to check whether a coro.id describes the enclosing function or it belongs to a different function that was later inlined.

CoroSplit now creates three subfunctions:
# f$resume - resume logic
# f$destroy - cleanup logic, followed by a deallocation code
# f$cleanup - just the cleanup code

CoroElide pass during devirtualization replaces coro.destroy with either f$destroy or f$cleanup depending whether heap elision is performed or not.

Other fixes, improvements:
* Fixed buglet in Shape::buildFrame that was not creating coro.save properly if coroutine has more than one suspend point.

* Switched to using variable width suspend index field (no longer limited to 32 bit index field can be as little as i1 or as large as i<whatever-size_t-is>)

Reviewers: majnemer

Subscribers: llvm-commits, mehdi_amini

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279971 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 14:34:12 +00:00
Sanjay Patel
2c15995350 [InstCombine] use m_APInt to allow icmp (and X, Y), C folds for splat constant vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279937 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 18:18:00 +00:00
Elena Demikhovsky
1b2a8500af [Loop Vectorizer] Fixed memory confilict checks.
Fixed a bug in run-time checks for possible memory conflicts inside loop.
The bug is in Low <-> High boundaries calculation. The High boundary should be calculated as "last memory access pointer + element size".

Differential revision: https://reviews.llvm.org/D23176



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279930 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 08:53:53 +00:00
Adam Nemet
c96b33c2f4 [Inliner] Report when inlining fails because callee's def is unavailable
Summary:
This is obviously an interesting case because it may motivate code
restructuring or LTO.

Reporting this requires instantiation of ORE in the loop where the call
sites are first gathered.  I've checked compile-time
overhead *with* -Rpass-with-hotness and the worst slow-down was 6% in
mcf and quickly tailing off.  As before without -Rpass-with-hotness
there is no overhead.

Because this could be a pretty noisy diagnostics, it is currently
qualified as 'verbose'.  As of this patch, 'verbose' diagnostics are
only emitted with -Rpass-with-hotness, i.e. when the output is expected
to be filtered.

Reviewers: eraman, chandlerc, davidxl, hfinkel

Subscribers: tejohnson, Prazek, davide, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279860 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-26 20:21:05 +00:00
Tim Shen
943f7f4327 [MemCpy] Add comments for r279769
Differential Revision: https://reviews.llvm.org/D23846

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279778 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25 21:03:46 +00:00
Tim Shen
f65deb821d [MemCpy] Check for alias in performMemCpyToMemSetOptzn, instead of the identity of two operands
Summary:
This fixes pr29105. The reason is that lifetime marks creates new
aliasing pointers the original ones, but before this patch aliases
were not checked in performMemCpyToMemSetOptzn.

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279769 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25 19:27:26 +00:00
Sebastian Pop
21af1c9019 GVN-hoist: fix hoistingFromAllPaths for loops (PR29034)
It is invalid to hoist stores or loads if they are not executed on all paths
from the hoisting point to the exit of the function. In the testcase, there are
paths in the loop that do not execute the stores or the loads, and so hoisting
them within the loop is unsafe.

The problem is that the current implementation of hoistingFromAllPaths is
incomplete: it walks all blocks dominated by the hoisting point, and does not
return false when the loop contains a path on which the hoisted ld/st is
not executed.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279732 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25 11:55:47 +00:00
Xinliang David Li
1a1f08db0c [Profile] Propagate branch metadata properly in instcombine
Differential Revision: http://reviews.llvm.org/D23590



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279693 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25 00:26:32 +00:00
Sanjay Patel
66b84ccb05 [InstCombine] use m_APInt to allow icmp eq/ne (shr X, C2), C folds for splat constant vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279677 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-24 22:22:06 +00:00
Matthew Simpson
428e79c2bb [LV] Unify vector and scalar maps
This patch unifies the data structures we use for mapping instructions from the
original loop to their corresponding instructions in the new loop. Previously,
we maintained two distinct maps for this purpose: WidenMap and ScalarIVMap.
WidenMap maintained the vector values each instruction from the old loop was
represented with, and ScalarIVMap maintained the scalar values each scalarized
induction variable was represented with. With this patch, all values created
for the new loop are maintained in VectorLoopValueMap.

The change allows for several simplifications. Previously, when an instruction
was scalarized, we had to insert the scalar values into vectors in order to
maintain the mapping in WidenMap. Then, if a user of the scalarized value was
also scalar, we had to extract the scalar values from the temporary vector we
created. We now aovid these unnecessary scalar-to-vector-to-scalar conversions.
If a scalarized value is used by a scalar instruction, the scalar value is used
directly. However, if the scalarized value is needed by a vector instruction,
we generate the needed insertelement instructions on-demand.

A common idiom in several locations in the code (including the scalarization
code), is to first get the vector values an instruction from the original loop
maps to, and then extract a particular scalar value. This patch adds
getScalarValue for this purpose along side getVectorValue as an interface into
VectorLoopValueMap. These functions work together to return the requested
values if they're available or to produce them if they're not.

The mapping has also be made less permissive. Entries can be added to
VectorLoopValue map with the new initVector and initScalar functions.
getVectorValue has been modified to return a constant reference to the mapped
entries.

There's no real functional change with this patch; however, in some cases we
will generate slightly different code. For example, instead of an insertelement
sequence following the definition of an instruction, it will now precede the
first use of that instruction. This can be seen in the test case changes.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279649 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-24 18:23:17 +00:00
Sanjoy Das
09f0b3c147 [SCCP] Don't delete side-effecting instructions
I'm not sure if the `!isa<CallInst>(Inst) &&
!isa<TerminatorInst>(Inst))` bit is correct either, but this fixes the
case we know is broken.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279647 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-24 18:10:21 +00:00
Gil Rapaport
568c0d2c94 [Loop Vectorizer] Support predication of div/rem
div/rem instructions in basic blocks that require predication currently prevent
vectorization. This patch extends the existing mechanism for predicating stores
to handle other instructions and leverages it to predicate divs and rems.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279620 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-24 11:37:57 +00:00
Gor Nishanov
c5f116c1ce [Coroutines] Part 8: Coroutine Frame Building algorithm
Summary:
This patch adds coroutine frame building algorithm. Now, simple coroutines such as ex0.ll and ex1.ll (first examples from docs\Coroutines.rst can be compiled).

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. (https://reviews.llvm.org/D23461)
8. Coroutine Frame Building algorithm  <= we are here
9. Add f.cleanup subfunction.
10+. The rest of the logic

Reviewers: majnemer

Subscribers: mehdi_amini, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279609 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-24 04:44:35 +00:00
Matthew Simpson
35b8916582 [SLP] Avoid signed integer overflow
The test case included with r279125 exposed an existing signed integer
overflow. Since getTreeCost can return INT_MAX, we can't sum this cost together
with other costs, such as getReductionCost.

This patch removes the possibility of assigning a cost of INT_MAX. Since we
were previously using INT_MAX as an indicator for "should not vectorize", we
now explicitly check this condition with "isTreeTinyAndNotFullyVectorizable"
before computing a cost.

This patch adds a run-line to the test case used for r279125 that ensures we
don't vectorize. Previously, this line would vectorize the test case by chance
due to undefined behavior in the cost calculation.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279562 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-23 20:48:50 +00:00
Sanjay Patel
d439a66862 [InstSimplify] allow icmp with constant folds for splat vectors, part 2
Completes the m_APInt changes for simplifyICmpWithConstant().

Other commits in this series:
https://reviews.llvm.org/rL279492
https://reviews.llvm.org/rL279530
https://reviews.llvm.org/rL279534
https://reviews.llvm.org/rL279538



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279543 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-23 18:00:51 +00:00
Sanjay Patel
405b046cb5 [InstSimplify] allow icmp with constant folds for splat vectors, part 1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279538 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-23 17:30:56 +00:00
Sanjay Patel
f98248330c [InstSimplify] add tests to show missing vector icmp folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279534 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-23 17:13:38 +00:00
Sanjay Patel
d09e4ee68a [InstSimplify] move icmp with constant tests to another file; NFC
...because like the corresponding code, this is just too big to keep adding to.
And the next step is to add a vector version of each of these tests to show
missed folds.

Also, auto-generate CHECK lines and add comments for the tests that correspond to
the source code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279530 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-23 16:46:53 +00:00
Sanjay Patel
e3ecb56f22 [InstCombine] use m_APInt to allow icmp (shr exact X, Y), 0 folds for splat constant vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279472 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 20:45:06 +00:00
James Molloy
6a5d369249 [SimplifyCFG] Rewrite SinkThenElseCodeToEnd
[Recommitting now an unrelated assertion in SROA is sorted out]

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.

Round 4. This time we should handle all instructions correctly, and not replace any operands that need to be constant with variables.

This was really hard to determine safely, so the helper function should be put into the Instruction API. I'll do that as a followup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279460 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 19:07:15 +00:00
Jun Bum Lim
11ee15bafc [InstCombine] Allow sinking from unique predecessor with multiple edges
Summary: We can allow sinking if the single user block has only one unique predecessor, regardless of the number of edges. Note that a switch statement with multiple cases can have the same destination.

Reviewers: mcrosier, majnemer, spatel, reames

Subscribers: reames, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279448 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 18:21:56 +00:00
James Molloy
abcbb63bbf Revert "[SimplifyCFG] Rewrite SinkThenElseCodeToEnd"
This reverts commit r279443. It caused buildbot failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279447 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 18:13:12 +00:00
James Molloy
e093ba31a4 [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.

Round 4. This time we should handle all instructions correctly, and not replace any operands that need to be constant with variables.

This was really hard to determine safely, so the helper function should be put into the Instruction API. I'll do that as a followup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279443 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 17:40:23 +00:00
Artur Pilipenko
a267310794 Revert -r278267 [ValueTracking] An improvement to IR ValueTracking on Non-negative Integers
This change cause performance regression on MultiSource/Benchmarks/TSVC/Symbolics-flt/Symbolics-flt from LNT and some other bechmarks.

See https://reviews.llvm.org/D18777 for details.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279433 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 13:14:07 +00:00
Artur Pilipenko
d8d6388a44 Revert -r278269 [IndVarSimplify] Eliminate zext of a signed IV when the IV is known to be non-negative
This change needs to be reverted in order to revert -r278267 which cause performance regression on MultiSource/Benchmarks/TSVC/Symbolics-flt/Symbolics-flt from LNT and some other bechmarks.

See comments on https://reviews.llvm.org/D18777 for details.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279432 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 13:12:07 +00:00
Balaram Makam
b10dff9eae [PM] Port LoopDataPrefetch AArch64 tests to new pass manager
Reviewers: mcrosier, tejohnson

Subscribers: aemerson, rengolin, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279431 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-22 12:59:58 +00:00
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