OSDN Git Service

android-x86/external-llvm.git
8 years ago[X86][SSE] Consistently use the target shuffle root value type for vector size calcul...
Simon Pilgrim [Fri, 5 Aug 2016 13:02:53 +0000 (13:02 +0000)]
[X86][SSE] Consistently use the target shuffle root value type for vector size calculations. NFCI.

Preparation for adding 2 input support so we want to avoid unnecessary references to the input value type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277814 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoLLLexer.cpp: Avoid using BitsToDouble() to preserve SNaN like "double 0x7FF4000000000...
NAKAMURA Takumi [Fri, 5 Aug 2016 11:59:49 +0000 (11:59 +0000)]
LLLexer.cpp: Avoid using BitsToDouble() to preserve SNaN like "double 0x7FF4000000000000".

We should not use double (or float) in the LLVM, unless it is really needed. x87 FP register doesn't preserve SNaN to move the value.

FIXME: APFloat() may have the constructor by raw bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277813 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoReformat.
NAKAMURA Takumi [Fri, 5 Aug 2016 11:59:45 +0000 (11:59 +0000)]
Reformat.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277812 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoAdd a missing backslash to my previous commit
John Brawn [Fri, 5 Aug 2016 11:17:43 +0000 (11:17 +0000)]
Add a missing backslash to my previous commit

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277809 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86][SSE] Added target shuffle combine binary compute matching function. NFCI.
Simon Pilgrim [Fri, 5 Aug 2016 11:16:53 +0000 (11:16 +0000)]
[X86][SSE] Added target shuffle combine binary compute matching function. NFCI.

Added matchBinaryPermuteVectorShuffle and moved the blend+zero and insertps matching code into it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277808 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoReapply r276973 "Adjust Registry interface to not require plugins to export a registry"
John Brawn [Fri, 5 Aug 2016 11:01:08 +0000 (11:01 +0000)]
Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"

This differs from the previous version by being more careful about template
instantiation/specialization in order to prevent errors when building with
clang -Werror. Specifically:
 * begin is not defined in the template and is instead instantiated when Head
   is. I think the warning when we don't do that is wrong (PR28815) but for now
   at least do it this way to avoid the warning.
 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
   instead provide a template definition then do explicit instantiation. No
   compiler I've tried has problems with doing it the other way, but strictly
   speaking it's not permitted by the C++ standard so better safe than sorry.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277806 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[PowerPC] fix passing long double arguments to function (soft-float)
Strahinja Petrovic [Fri, 5 Aug 2016 08:47:26 +0000 (08:47 +0000)]
[PowerPC] fix passing long double arguments to function (soft-float)

This patch fixes passing long double type arguments to function in
soft float mode. If there is less than 4 argument registers free
(long double type is mapped in 4 gpr registers in soft float mode)
long double type argument must be passed through stack.
Differential Revision: https://reviews.llvm.org/D20114.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277804 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] try to fold (select C, (sext A), B) into logical ops
Nicolai Haehnle [Fri, 5 Aug 2016 08:22:29 +0000 (08:22 +0000)]
[InstCombine] try to fold (select C, (sext A), B) into logical ops

Summary:
Turn (select C, (sext A), B) into (sext (select C, A, B')) when A is i1 and
B is a compatible constant, also for zext instead of sext. This will then be
further folded into logical operations.

The transformation would be valid for non-i1 types as well, but other parts of
InstCombine prefer to have sext from non-i1 as an operand of select.

Motivated by the shader compiler frontend in Mesa for AMDGPU, which emits i32
for boolean operations. With this change, the boolean logic is fully
recovered.

Reviewers: majnemer, spatel, tstellarAMD

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277801 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoInstCombine: Clean up some trailing whitespace. NFC
Justin Bogner [Fri, 5 Aug 2016 01:09:48 +0000 (01:09 +0000)]
InstCombine: Clean up some trailing whitespace. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277793 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoInstCombine: Replace some never-null pointers with references. NFC
Justin Bogner [Fri, 5 Aug 2016 01:06:44 +0000 (01:06 +0000)]
InstCombine: Replace some never-null pointers with references. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277792 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[LIT][Darwin] Change %ld64 to be prefixed with DYLD_INSERT_LIBRARIES
Bruno Cardoso Lopes [Thu, 4 Aug 2016 23:58:30 +0000 (23:58 +0000)]
[LIT][Darwin] Change %ld64 to be prefixed with DYLD_INSERT_LIBRARIES

Followup from r277778, after Mehdi's comments.

Expand %ld64 to perform the necessary preload instead, that way new
tests do not need to worry about setting up DYLD_INSERT_LIBRARIES
themselves.

rdar://problem/24300926

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277788 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVN-hoist: enable by default
Sebastian Pop [Thu, 4 Aug 2016 23:49:07 +0000 (23:49 +0000)]
GVN-hoist: enable by default

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277786 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVN-hoist: fix early exit logic
Sebastian Pop [Thu, 4 Aug 2016 23:49:05 +0000 (23:49 +0000)]
GVN-hoist: fix early exit logic

The patch splits a complex && if condition into easier to read and understand
logic.  That wrong early exit condition was letting some instructions with not
all operands available pass through when HoistingGeps was true.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277785 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoIR: Provide an IRBuilder Inserter that calls a callback after insertion
Justin Bogner [Thu, 4 Aug 2016 23:41:01 +0000 (23:41 +0000)]
IR: Provide an IRBuilder Inserter that calls a callback after insertion

Add a generalized IRBuilderCallbackInserter, which is just given a
callback to execute after insertion. This can be used to get rid of
the custom inserter in InstCombine, which will in turn allow me to add
target specific InstCombineCalls API for intrinsics without horrible
layering violations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277784 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[LV, X86] Be more optimistic about vectorizing shifts.
Michael Kuperstein [Thu, 4 Aug 2016 22:48:03 +0000 (22:48 +0000)]
[LV, X86] Be more optimistic about vectorizing shifts.

Shifts with a uniform but non-constant count were considered very expensive to
vectorize, because the splat of the uniform count and the shift would tend to
appear in different blocks. That made the splat invisible to ISel, and we'd
scalarize the shift at codegen time.

Since r201655, CodeGenPrepare sinks those splats to be next to their use, and we
are able to select the appropriate vector shifts. This updates the cost model to
to take this into account by making shifts by a uniform cheap again.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277782 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (mul X, C1), C2 folds for splat constant...
Sanjay Patel [Thu, 4 Aug 2016 22:19:27 +0000 (22:19 +0000)]
[InstCombine] use m_APInt to allow icmp eq (mul X, C1), C2 folds for splat constant vectors

This concludes the splat vector enhancements for foldICmpEqualityWithConstant().
Other commits in this series:
https://reviews.llvm.org/rL277762
https://reviews.llvm.org/rL277752
https://reviews.llvm.org/rL277738
https://reviews.llvm.org/rL277731
https://reviews.llvm.org/rL277659
https://reviews.llvm.org/rL277638
https://reviews.llvm.org/rL277629

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277779 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[LIT][Darwin] Preload libclang_rt.asan_osx_dynamic.dylib when necessary
Bruno Cardoso Lopes [Thu, 4 Aug 2016 22:01:38 +0000 (22:01 +0000)]
[LIT][Darwin] Preload libclang_rt.asan_osx_dynamic.dylib when necessary

Green Dragon's darwin stage2 asan bot fails on some checks:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check

  test/tools/lto/hide-linkonce-odr.ll
  test/tools/lto/opt-level.ll

ERROR: Interceptors are not working. This may be because
AddressSanitizer is loaded too late (e.g. via dlopen)

To fix this, %ld64 needs to load 'libclang_rt.asan_osx_dynamic.dylib'
before libLTO.dylib, via DYLD_INSERT_LIBRARIES. This won't work by
updating config.environment, since some shim binary in the way scrubs
the env vars. Instead, provide the path to this lib through %asanrtlib,
which can then be used by tests directly with DYLD_INSERT_LIBRARIES.

rdar://problem/24300926

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277778 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoClean up the logic of the Archive::Child::Child() with an assert to know Err is not...
Kevin Enderby [Thu, 4 Aug 2016 21:54:19 +0000 (21:54 +0000)]
Clean up the logic of the Archive::Child::Child() with an assert to know Err is not a nullptr
when we are pointed at real data.

David Blaikie pointed out some odd logic in the case the Err value was a nullptr and
Lang Hames suggested it could be cleaned it up with an assert to know that Err is
not a nullptr when we are pointed at real data.  As only in the case of constructing
the sentinel value by pointing it at null data is Err is permitted to be a nullptr,
since no error could occur in that case.

With this change the testing for “if (Err)” is removed from the constructor’s logic
and *Err is used directly without any check after the assert().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277776 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGlobalISel: extend add widening to SUB, MUL, OR, AND and XOR.
Tim Northover [Thu, 4 Aug 2016 21:39:49 +0000 (21:39 +0000)]
GlobalISel: extend add widening to SUB, MUL, OR, AND and XOR.

These are the operations that are trivially identical. Division is omitted for
now because you need to use the correct sign/zero extension.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277775 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGlobalISel: add support for G_MUL
Tim Northover [Thu, 4 Aug 2016 21:39:44 +0000 (21:39 +0000)]
GlobalISel: add support for G_MUL

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277774 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[CloneFunction] Add a testcase for r277691/r277693
David Majnemer [Thu, 4 Aug 2016 21:28:59 +0000 (21:28 +0000)]
[CloneFunction] Add a testcase for r277691/r277693

PR28848 had a very nice reduction of the underlying cause of the bug.
Our ValueMap had, in an entry for an Instruction, a ConstantInt.

This is not at all unexpected but should be handled properly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277773 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[Mach0YAML] Change n_type from uint8_t to llvm::yaml::Hex8
Chris Bieneman [Thu, 4 Aug 2016 21:07:39 +0000 (21:07 +0000)]
[Mach0YAML] Change n_type from uint8_t to llvm::yaml::Hex8

Since this field is generally masked, it is way easier to understand it as a Hex value than decimal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277770 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGlobalISel: implement narrowing for G_ADD.
Tim Northover [Thu, 4 Aug 2016 20:54:13 +0000 (20:54 +0000)]
GlobalISel: implement narrowing for G_ADD.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277769 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGlobalISel: refuse to halve size of 1-byte & odd-sized LLTs.
Tim Northover [Thu, 4 Aug 2016 20:54:05 +0000 (20:54 +0000)]
GlobalISel: refuse to halve size  of 1-byte & odd-sized LLTs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277768 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVNHoist: Don't hoist convergent calls
Matt Arsenault [Thu, 4 Aug 2016 20:52:57 +0000 (20:52 +0000)]
GVNHoist: Don't hoist convergent calls

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277767 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[ExecutionEngine] Refactor - Roll JITSymbolFlags functionality into JITSymbol.h
Lang Hames [Thu, 4 Aug 2016 20:32:37 +0000 (20:32 +0000)]
[ExecutionEngine] Refactor - Roll JITSymbolFlags functionality into JITSymbol.h
and remove the JITSymbolFlags header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277766 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[coroutines] Part 4[ab]: Coroutine Devirtualization: Lower coro.resume and coro.destroy.
David Majnemer [Thu, 4 Aug 2016 20:30:07 +0000 (20:30 +0000)]
[coroutines] Part 4[ab]: Coroutine Devirtualization: Lower coro.resume and coro.destroy.

This is the forth patch in the coroutine series. CoroEaly pass now lowers coro.resume
and coro.destroy intrinsics by replacing them with an indirect call to an address
returned by coro.subfn.addr intrinsic. This is done so that CGPassManager recognizes
devirtualization when CoroElide replaces a call to coro.subfn.addr with an appropriate
function address.

Patch by Gor Nishanov!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277765 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (and X, C1), C2 folds for splat constant...
Sanjay Patel [Thu, 4 Aug 2016 20:05:02 +0000 (20:05 +0000)]
[InstCombine] use m_APInt to allow icmp eq (and X, C1), C2 folds for splat constant vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277762 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[OpenCL] Add missing tests for getOCLTypeName
Yaxun Liu [Thu, 4 Aug 2016 19:45:00 +0000 (19:45 +0000)]
[OpenCL] Add missing tests for getOCLTypeName

Adding missing tests for OCL type names for half, float, double, char, short, long, and unknown.

Patch by Aaron En Ye Shi.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277759 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[CodeView] Use llvm::Error instead of std::error_code.
Zachary Turner [Thu, 4 Aug 2016 19:39:55 +0000 (19:39 +0000)]
[CodeView] Use llvm::Error instead of std::error_code.

This eliminates the remnants of std::error_code from the
DebugInfo libraries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277758 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoAArch64: don't assume all i128s are BUILD_PAIRs
Tim Northover [Thu, 4 Aug 2016 19:32:28 +0000 (19:32 +0000)]
AArch64: don't assume all i128s are BUILD_PAIRs

It leads to a crash when they're not. I'm *sure* I've made this mistake before,
at least once.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277755 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[macho2yaml] String table can contain null strings
Chris Bieneman [Thu, 4 Aug 2016 19:19:25 +0000 (19:19 +0000)]
[macho2yaml] String table can contain null strings

Since the string table being read from the MachO is a properly bounded StringRef including null strings is safe and reasonable.

This occurs frequently with stripped binaries where the string table has been modified.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277753 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (or X, C1), C2 folds for splat constant...
Sanjay Patel [Thu, 4 Aug 2016 19:12:12 +0000 (19:12 +0000)]
[InstCombine] use m_APInt to allow icmp eq (or X, C1), C2 folds for splat constant vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277752 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGlobalISel: also add G_TRUNC to IRTranslator.
Tim Northover [Thu, 4 Aug 2016 18:35:17 +0000 (18:35 +0000)]
GlobalISel: also add G_TRUNC to IRTranslator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277749 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGlobalISel: add code to widen scalar G_ADD
Tim Northover [Thu, 4 Aug 2016 18:35:11 +0000 (18:35 +0000)]
GlobalISel: add code to widen scalar G_ADD

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277747 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoremove FIXME comments (fixed with r277738)
Sanjay Patel [Thu, 4 Aug 2016 18:14:02 +0000 (18:14 +0000)]
remove FIXME comments (fixed with r277738)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277744 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[WebAssembly] Check return value of getRegForValue in FastISel
Derek Schuff [Thu, 4 Aug 2016 18:01:52 +0000 (18:01 +0000)]
[WebAssembly] Check return value of getRegForValue in FastISel

Previously, FastISel for WebAssembly wasn't checking the return value of
`getRegForValue` in certain cases, which would generate instructions
referencing NoReg. This patch fixes this behavior.

Patch by Dominic Chen

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277742 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[llvm-cov] Add some documentation for the -tab-size option
Vedant Kumar [Thu, 4 Aug 2016 18:00:42 +0000 (18:00 +0000)]
[llvm-cov] Add some documentation for the -tab-size option

Also, un-hide the cl::opt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277741 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[Hexagon] Validate register class when doing bit simplification
Krzysztof Parzyszek [Thu, 4 Aug 2016 17:56:19 +0000 (17:56 +0000)]
[Hexagon] Validate register class when doing bit simplification

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277740 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (op X, Y), C folds for splat constant...
Sanjay Patel [Thu, 4 Aug 2016 17:48:04 +0000 (17:48 +0000)]
[InstCombine] use m_APInt to allow icmp eq (op X, Y), C folds for splat constant vectors

I'm removing a misplaced pair of more specific folds from InstCombine in this patch as well,
so we know where those folds are happening in InstSimplify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277738 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86][SSE] Rename target shuffle unary permute matching function. NFCI.
Simon Pilgrim [Thu, 4 Aug 2016 17:16:50 +0000 (17:16 +0000)]
[X86][SSE] Rename target shuffle unary permute matching function. NFCI.

In preparation for adding a binary permute matching function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277737 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoadd tests for missing vector folds
Sanjay Patel [Thu, 4 Aug 2016 16:48:30 +0000 (16:48 +0000)]
add tests for missing vector folds

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277736 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoLoadStoreVectorizer: Remove TargetBaseAlign. Keep alignment for stack adjustments.
Alina Sbirlea [Thu, 4 Aug 2016 16:38:44 +0000 (16:38 +0000)]
LoadStoreVectorizer: Remove TargetBaseAlign. Keep alignment for stack adjustments.

Summary:
TargetBaseAlign is no longer required since LSV checks if target allows misaligned accesses.
A constant defining a base alignment is still needed for stack accesses where alignment can be adjusted.

Previous patch (D22936) was reverted because tests were failing. This patch also fixes the cause of those failures:
- x86 failing tests either did not have the right target, or the right alignment.
- NVPTX failing tests did not have the right alignment.
- AMDGPU failing test (merge-stores) should allow vectorization with the given alignment but the target info
  considers <3xi32> a non-standard type and gives up early. This patch removes the condition and only checks
  for a maximum size allowed and relies on the next condition checking for %4 for correctness.
  This should be revisited to include 3xi32 as a MVT type (on arsenm's non-immediate todo list).

Note that checking the sizeInBits for a MVT is undefined (leads to an assertion failure),
so we need to create an EVT, hence the interface change in allowsMisaligned to include the Context.

Reviewers: arsenm, jlebar, tstellarAMD

Subscribers: jholewinski, arsenm, mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277735 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoShamelessly add myself to CREDITS.TXT
Adrian Prantl [Thu, 4 Aug 2016 16:28:22 +0000 (16:28 +0000)]
Shamelessly add myself to CREDITS.TXT

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277734 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[mips] Set Personality and LSDA encoding for FreeBSD
Daniel Sanders [Thu, 4 Aug 2016 15:36:03 +0000 (15:36 +0000)]
[mips] Set Personality and LSDA encoding for FreeBSD

Reviewers: seanbruno, sdardis

Subscribers: tberghammer, danalbert, srhines, dsanders, sdardis, llvm-commits, seanbruno

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277732 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (sub C1, X), C2 folds for splat constant...
Sanjay Patel [Thu, 4 Aug 2016 15:19:25 +0000 (15:19 +0000)]
[InstCombine] use m_APInt to allow icmp eq (sub C1, X), C2 folds for splat constant vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277731 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86][SSE] Split off shuffle mask canonicalization from lowerVectorShuffle. NFCI.
Simon Pilgrim [Thu, 4 Aug 2016 14:21:32 +0000 (14:21 +0000)]
[X86][SSE] Split off shuffle mask canonicalization from lowerVectorShuffle. NFCI.

The new function now returns true if the shuffle should be commuted.

This will allow target shuffle combines to share the code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277728 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[Hexagon] Clear kill flags from modified registers in peephole optimizer
Krzysztof Parzyszek [Thu, 4 Aug 2016 14:17:16 +0000 (14:17 +0000)]
[Hexagon] Clear kill flags from modified registers in peephole optimizer

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277727 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86] Heuristic to selectively build Newton-Raphson SQRT estimation
Nikolai Bozhenov [Thu, 4 Aug 2016 12:47:28 +0000 (12:47 +0000)]
[X86] Heuristic to selectively build Newton-Raphson SQRT estimation

On modern Intel processors hardware SQRT in many cases is faster than RSQRT
followed by Newton-Raphson refinement. The patch introduces a simple heuristic
to choose between hardware SQRT instruction and Newton-Raphson software
estimation.

The patch treats scalars and vectors differently. The heuristic is that for
scalars the compiler should optimize for latency while for vectors it should
optimize for throughput. It is based on the assumption that throughput bound
code is likely to be vectorized.

Basically, the patch disables scalar NR for big cores and disables NR completely
for Skylake. Firstly, scalar SQRT has shorter latency than NR code in big cores.
Secondly, vector SQRT has been greatly improved in Skylake and has better
throughput compared to NR.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277725 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[mips][microMIPS] Implement CFC1, CFC2, CTC1 and CTC2 instructions
Hrvoje Varga [Thu, 4 Aug 2016 11:22:52 +0000 (11:22 +0000)]
[mips][microMIPS] Implement CFC1, CFC2, CTC1 and CTC2 instructions
Differential Revision: https://reviews.llvm.org/D22347

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277719 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86] Dropped XOP ctbits checks - they match the AVX checks
Simon Pilgrim [Thu, 4 Aug 2016 11:04:13 +0000 (11:04 +0000)]
[X86] Dropped XOP ctbits checks - they match the AVX checks

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277718 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86][SSE] Add initial costs for vector CTTZ/CTLZ
Simon Pilgrim [Thu, 4 Aug 2016 10:51:41 +0000 (10:51 +0000)]
[X86][SSE] Add initial costs for vector CTTZ/CTLZ

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277716 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[LLVM-COV]Replace tabs to the space indentations in the HTML coverage report.
Ying Yi [Thu, 4 Aug 2016 10:39:43 +0000 (10:39 +0000)]
[LLVM-COV]Replace tabs to the space indentations in the HTML coverage report.

When using orbis-llvm-cov.exe to generate the HTML report, the HTML report
can look quite different to the source file if it includes tabs.The default
tab size is 2 spaces instead of 8 spaces. A command line switch is
be added to set the tab size.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277715 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoRemove LLVM_ENABLE_LIBCXXABI
Jonas Hahnfeld [Thu, 4 Aug 2016 10:24:48 +0000 (10:24 +0000)]
Remove LLVM_ENABLE_LIBCXXABI

libc++.so is now a linker script that includes -lc++abi if necessary.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277714 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86][SSE] Don't decide when to scalarize CTTZ/CTLZ for performance at lowering ...
Simon Pilgrim [Thu, 4 Aug 2016 10:14:39 +0000 (10:14 +0000)]
[X86][SSE] Don't decide when to scalarize CTTZ/CTLZ for performance at lowering - this is what cost models are for

Improved CTTZ/CTLZ costings will be added shortly

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277713 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[mips] Enable tail calls by default
Simon Dardis [Thu, 4 Aug 2016 09:17:07 +0000 (09:17 +0000)]
[mips] Enable tail calls by default

Enable tail calls by default for (micro)MIPS(64).

microMIPS is slightly more tricky than doing it for MIPS(R6) or microMIPSR6.
microMIPS has two instruction encodings: 16bit and 32bit along with some
restrictions on the size of the instruction that can fill the delay slot.
For safe tail calls for microMIPS, the delay slot filler attempts to find
a correct size instruction for the delay slot of TAILCALL pseudos.

Reviewers: dsanders, vkalintris

Subscribers: jfb, dsanders, sdardis, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277708 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoTypo fix in comment. NFC
Diana Picus [Thu, 4 Aug 2016 08:25:08 +0000 (08:25 +0000)]
Typo fix in comment. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277704 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[XRay] Align entry and return sleds to 2 byte boundaries
Dean Michael Berris [Thu, 4 Aug 2016 07:37:28 +0000 (07:37 +0000)]
[XRay] Align entry and return sleds to 2 byte boundaries

This should ensure that we can atomically write two bytes (on top of the
retq and the one past it) and have those two bytes not straddle cache
lines.

We also move the label past the alignment instruction so that we can refer
to the actual first instruction, as opposed to potential padding before the
aligned instruction.

Update the tests to allow us to reflect the new order of assembly.

Reviewers: rSerge, echristo, majnemer

Subscribers: llvm-commits, mehdi_amini

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277701 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoAMDGPU: Fix a slow test by using basic regalloc
Matt Arsenault [Thu, 4 Aug 2016 07:04:54 +0000 (07:04 +0000)]
AMDGPU: Fix a slow test by using basic regalloc

This just tests that the register limit isn't exceeded,
so the regisetr allocation doesn't need to be great.'

The critically slow part is all in greedy RA, so
switch to basic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277700 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoFix intrinsics.ll test
Amaury Sechet [Thu, 4 Aug 2016 05:35:25 +0000 (05:35 +0000)]
Fix intrinsics.ll test

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277695 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoAdd popcount(n) == bitsize(n) -> n == -1 transformation.
Amaury Sechet [Thu, 4 Aug 2016 05:27:20 +0000 (05:27 +0000)]
Add popcount(n) == bitsize(n)  -> n == -1 transformation.

Summary: As per title.

Reviewers: majnemer, spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277694 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoForgot the dyn_cast_or_null intended for r277691.
David Majnemer [Thu, 4 Aug 2016 04:47:18 +0000 (04:47 +0000)]
Forgot the dyn_cast_or_null intended for r277691.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277693 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoReinstate "[CloneFunction] Don't remove side effecting calls"
David Majnemer [Thu, 4 Aug 2016 04:24:02 +0000 (04:24 +0000)]
Reinstate "[CloneFunction] Don't remove side effecting calls"

This reinstates r277611 + r277614 and reverts r277642.  A cast_or_null
should have been a dyn_cast_or_null.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277691 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoRevert "GVN-hoist: enable by default" & "Make GVN Hoisting obey optnone/bisect."
Bruno Cardoso Lopes [Thu, 4 Aug 2016 04:16:24 +0000 (04:16 +0000)]
Revert "GVN-hoist: enable by default" & "Make GVN Hoisting obey optnone/bisect."

This reverts commits r277685 & r277688. r277685 broke compiler-rt
compilation http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/23335
and r277685 is a followup from it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277690 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[PM] Change the name of the repeating utility to something less
Chandler Carruth [Thu, 4 Aug 2016 03:52:53 +0000 (03:52 +0000)]
[PM] Change the name of the repeating utility to something less
overloaded (and simpler).

Sean rightly pointed out in code review that we've started using
"wrapper pass" as a specific part of the old pass manager, and in fact
it is more applicable there. Here, we really have a pass *template* to
build a repeated pass, so call it that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277689 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoMake GVN Hoisting obey optnone/bisect.
Sebastian Pop [Thu, 4 Aug 2016 02:05:08 +0000 (02:05 +0000)]
Make GVN Hoisting obey optnone/bisect.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277688 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVN-hoist: enable by default
Sebastian Pop [Thu, 4 Aug 2016 01:59:42 +0000 (01:59 +0000)]
GVN-hoist: enable by default

As we addressed all compilation time problems with GVN-hoist
https://llvm.org/bugs/show_bug.cgi?id=28670
this patch turns GVN-hoist back by default.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277685 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agopdbdump: Add a test to verify the result of PDB -> YAML -> PDB conversions.
Rui Ueyama [Wed, 3 Aug 2016 23:54:39 +0000 (23:54 +0000)]
pdbdump: Add a test to verify the result of PDB -> YAML -> PDB conversions.

Currently not all information can be restored from YAML.
This test verifies only the PDB header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277682 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agopdbdump: Fix crash bug.
Rui Ueyama [Wed, 3 Aug 2016 23:43:23 +0000 (23:43 +0000)]
pdbdump: Fix crash bug.

pdbdump calls DbiStreamBuilder::commit through PDBFileBuilder::commit
without calling DbiStreamBuilder::finalize. Because `finalize` initializes
`Header` member, `Header` remained nullptr which caused a crash bug.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277681 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agollvm-profdata: Clarify the top level help
Justin Bogner [Wed, 3 Aug 2016 23:10:51 +0000 (23:10 +0000)]
llvm-profdata: Clarify the top level help

It wasn't very obvious that you're supposed to call help on the
subcommands. This should help.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277678 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoRenameIndependentSubregs: Fix liveness query in rewriteOperands()
Matthias Braun [Wed, 3 Aug 2016 22:37:47 +0000 (22:37 +0000)]
RenameIndependentSubregs: Fix liveness query in rewriteOperands()

rewriteOperands() always performed liveness queries at the base index
rather than the RegSlot/Base as apropriate for the machine operand. This
could lead to illegal rewriting in some cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277661 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (add X, C1), C2 folds for splat constant...
Sanjay Patel [Wed, 3 Aug 2016 22:08:44 +0000 (22:08 +0000)]
[InstCombine] use m_APInt to allow icmp eq (add X, C1), C2 folds for splat constant vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277659 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoClean up of libObject/Archive interfaces and change the last three uses of ErrorOr<>
Kevin Enderby [Wed, 3 Aug 2016 21:57:47 +0000 (21:57 +0000)]
Clean up of libObject/Archive interfaces and change the last three uses of ErrorOr<>
changing them to Expected<> to allow them to pass through llvm Errors.
No functional change.

This commit by itself will break the next lld builds.  I’ll be committing the
matching change for lld immediately next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277656 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[PPC] Handling CallInst in PPCBoolRetToInt
Guozhi Wei [Wed, 3 Aug 2016 21:43:51 +0000 (21:43 +0000)]
[PPC] Handling CallInst in PPCBoolRetToInt

This patch fixes pr25548.

Current implementation of PPCBoolRetToInt doesn't handle CallInst correctly, so it failed to do the intended optimization when there is a CallInst with parameters. This patch fixed that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277655 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoRevert "[ARM] Constant Materialize: imms with specific value can be encoded into...
Bruno Cardoso Lopes [Wed, 3 Aug 2016 21:26:21 +0000 (21:26 +0000)]
Revert "[ARM] Constant Materialize: imms with specific value can be encoded into mov.w"

This reverts commit r277610 / d619aa8878c3dafcc0d29a46517f63ff3209fdd4.

This make subtarget-no-movt.ll fail in
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26892,

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277654 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[MSSA] Fix a bug in MemorySSA's move ctor.
George Burgess IV [Wed, 3 Aug 2016 21:07:52 +0000 (21:07 +0000)]
[MSSA] Fix a bug in MemorySSA's move ctor.

Not a correctness issue, but it would be nice if we didn't have to
recompute our block numbering (worst-case) every time we move MSSA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277652 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVN-hoist: limit the length of dependent instructions
Sebastian Pop [Wed, 3 Aug 2016 20:54:38 +0000 (20:54 +0000)]
GVN-hoist: limit the length of dependent instructions

Limit the number of times the while(1) loop is executed. With this restriction
the number of hoisted instructions does not change in a significant way on the
test-suite.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277651 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVN-hoist: compute DFS numbers once
Sebastian Pop [Wed, 3 Aug 2016 20:54:36 +0000 (20:54 +0000)]
GVN-hoist: compute DFS numbers once

With this patch we compute the DFS numbers of instructions only once and update
them during the code generation when an instruction gets hoisted.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277650 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoGVN-hoist: compute MSSA once per function (PR28670)
Sebastian Pop [Wed, 3 Aug 2016 20:54:33 +0000 (20:54 +0000)]
GVN-hoist: compute MSSA once per function (PR28670)

With this patch we compute the MemorySSA once and update it in the code generator.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277649 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[IndVars] Un-grepify test; NFC
Sanjoy Das [Wed, 3 Aug 2016 20:53:23 +0000 (20:53 +0000)]
[IndVars] Un-grepify test; NFC

Some of these tests need to be cleaned up further to make it obvious
what they're testing, but as a first step remove all instances of
"grep".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277648 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoopt-bisect-legacy-pass-manager.ll: Test only works with default triple configured
Matthias Braun [Wed, 3 Aug 2016 20:28:19 +0000 (20:28 +0000)]
opt-bisect-legacy-pass-manager.ll: Test only works with default triple configured

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277645 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoRevert "[CloneFunction] Don't remove side effecting calls"
Reid Kleckner [Wed, 3 Aug 2016 20:01:01 +0000 (20:01 +0000)]
Revert "[CloneFunction] Don't remove side effecting calls"

This reverts commit r277611 and the followup r277614.

Bootstrap builds and chromium builds are crashing during inlining after
this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277642 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[MSSA] clang-format. NFC.
George Burgess IV [Wed, 3 Aug 2016 19:59:11 +0000 (19:59 +0000)]
[MSSA] clang-format. NFC.

Didn't want to fold this in with r277640, since it touches bits that
aren't entirely related to r277640.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277641 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[MSSA] Add special handling for invariant/constant loads.
George Burgess IV [Wed, 3 Aug 2016 19:57:02 +0000 (19:57 +0000)]
[MSSA] Add special handling for invariant/constant loads.

This is a follow-up to r277637. It teaches MemorySSA that invariant
loads (and loads of provably constant memory) are always liveOnEntry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277640 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp eq (srem X, C1), C2 folds for splat constant...
Sanjay Patel [Wed, 3 Aug 2016 19:48:40 +0000 (19:48 +0000)]
[InstCombine] use m_APInt to allow icmp eq (srem X, C1), C2 folds for splat constant vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277638 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[MSSA] Add logic for special handling of atomics/volatiles.
George Burgess IV [Wed, 3 Aug 2016 19:39:54 +0000 (19:39 +0000)]
[MSSA] Add logic for special handling of atomics/volatiles.

This patch makes MemorySSA recognize atomic/volatile loads, and makes
MSSA treat said loads specially. This allows us to be a bit more
aggressive in some cases.

Administrative note: Revision was LGTM'ed by reames in person.
Additionally, this doesn't include the `invariant.load` recognition in
the differential revision, because I feel it's better to commit that
separately. Will commit soon.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277637 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoI can't reproduce this buildbot failure locally, so temporarily remove this test...
Elliot Colp [Wed, 3 Aug 2016 19:39:20 +0000 (19:39 +0000)]
I can't reproduce this buildbot failure locally, so temporarily remove this test while I investigate.

http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/27427

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277636 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] Refactor optimization of zext(or(icmp, icmp)) to enable more aggressive...
Tobias Grosser [Wed, 3 Aug 2016 19:30:35 +0000 (19:30 +0000)]
[InstCombine] Refactor optimization of zext(or(icmp, icmp)) to enable more aggressive cast-folding

Summary:
InstCombine unfolds expressions of the form `zext(or(icmp, icmp))` to `or(zext(icmp), zext(icmp))` such that in a later iteration of InstCombine the exposed `zext(icmp)` instructions can be optimized. We now combine this unfolding and the subsequent `zext(icmp)` optimization to be performed together. Since the unfolding doesn't happen separately anymore, we also again enable the folding of `logic(cast(icmp), cast(icmp))` expressions to `cast(logic(icmp, icmp))` which had been disabled due to its interference with the unfolding transformation.

Tested via `make check` and `lnt`.

Background
==========

For a better understanding on how it came to this change we subsequently summarize its history. In commit r275989 we've already tried to enable the folding of `logic(cast(icmp), cast(icmp))` to `cast(logic(icmp, icmp))` which had to be reverted in r276106 because it could lead to an endless loop in InstCombine (also see http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160718/374347.html). The root of this problem is that in `visitZExt()` in InstCombineCasts.cpp there also exists a reverse of the above folding transformation, that unfolds `zext(or(icmp, icmp))` to `or(zext(icmp), zext(icmp))` in order to expose `zext(icmp)` operations which would then possibly be eliminated by subsequent iterations of InstCombine. However, before these `zext(icmp)` would be eliminated the folding from r275989 could kick in and cause InstCombine to endlessly switch back and forth between the folding and the unfolding transformation. This is the reason why we now combine the `zext`-unfolding and the elimination of the exposed `zext(icmp)` to happen at one go because this enables us to still allow the cast-folding in `logic(cast(icmp), cast(icmp))` without entering an endless loop again.

Details on the submitted changes
================================

- In `visitZExt()` we combine the unfolding and optimization of `zext` instructions.
- In `transformZExtICmp()` we have to use `Builder->CreateIntCast()` instead of `CastInst::CreateIntegerCast()` to make sure that the new `CastInst` is inserted in a `BasicBlock`. The new calls to `transformZExtICmp()` that we introduce in `visitZExt()` would otherwise cause according assertions to be triggered (in our case this happend, for example, with lnt for the MultiSource/Applications/sqlite3 and SingleSource/Regression/C++/EH/recursive-throw tests). The subsequent usage of `replaceInstUsesWith()` is necessary to ensure that the new `CastInst` replaces the `ZExtInst` accordingly.
- In InstCombineAndOrXor.cpp we again allow the folding of casts on `icmp` instructions.
- The instruction order in the optimized IR for the zext-or-icmp.ll test case is different with the introduced changes.
- The test cases in zext.ll have been adopted from the reverted commits r275989 and r276105.

Reviewers: grosser, majnemer, spatel

Subscribers: eli.friedman, majnemer, llvm-commits

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

Contributed-by: Matthias Reisinger <d412vv1n@gmail.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277635 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoPass EphValues by const-ref as it is not modified in the callee
Sebastian Pop [Wed, 3 Aug 2016 19:13:50 +0000 (19:13 +0000)]
Pass EphValues by const-ref as it is not modified in the callee

Patch by Aditya Kumar.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277634 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] Cleanup select-bitext.ll tests
Nicolai Haehnle [Wed, 3 Aug 2016 19:10:13 +0000 (19:10 +0000)]
[InstCombine] Cleanup select-bitext.ll tests

Follow-up to r277596.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277633 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[X86][SSE] Enable target shuffle combining to combine multiple shuffle inputs.
Simon Pilgrim [Wed, 3 Aug 2016 19:08:24 +0000 (19:08 +0000)]
[X86][SSE] Enable target shuffle combining to combine multiple shuffle inputs.

We currently only support combining target shuffles that consist of a single source input (plus elements known to be undef/zero).

This patch generalizes the recursive combining of the target shuffle to collect all the inputs, merging any duplicates along the way, into a full set of src ops and its shuffle mask.

We uncover a number of cases where we have failed to combine a unary shuffle because the input has been duplicated and separated during lowering.

This will allow us to combine to 2-input shuffles in a future patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277631 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoReapply "More fixes to get good error messages for bad archives."
Vedant Kumar [Wed, 3 Aug 2016 19:02:50 +0000 (19:02 +0000)]
Reapply "More fixes to get good error messages for bad archives."

This reverts commit the revert commit r277627. The build errors
mentioned in r277627 were likely caused by an unclean build directory.
Sorry for the noise.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277630 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[InstCombine] use m_APInt to allow icmp (binop X, Y), C folds with constant splat...
Sanjay Patel [Wed, 3 Aug 2016 18:59:03 +0000 (18:59 +0000)]
[InstCombine] use m_APInt to allow icmp (binop X, Y), C folds with constant splat vectors

This removes the restriction for the icmp constant, but as noted by the FIXME comments,
we still need to change individual checks for binop operand constants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277629 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoRevert "More fixes to get good error messages for bad archives."
Vedant Kumar [Wed, 3 Aug 2016 18:44:32 +0000 (18:44 +0000)]
Revert "More fixes to get good error messages for bad archives."

This reverts commit r277540. It breaks the build with:

../lib/Object/Archive.cpp:264:41: error: return type of out-of-line definition of 'llvm::object::ArchiveMemberHeader::getUID' differs from that in the declaration
Expected<unsigned> ArchiveMemberHeader::getUID() const {
~~~~~~~~~~~~~~~~~~                      ^
include/llvm/Object/Archive.h:53:12: note: previous declaration is here
  unsigned getUID() const;
  ~~~~~~~~ ^

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277627 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[Hexagon] Generate COPY/REG_SEQUENCE more aggressively for vectors
Krzysztof Parzyszek [Wed, 3 Aug 2016 18:35:48 +0000 (18:35 +0000)]
[Hexagon] Generate COPY/REG_SEQUENCE more aggressively for vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277626 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoIR: Drop uniquing when an MDNode Value operand is deleted
Duncan P. N. Exon Smith [Wed, 3 Aug 2016 18:19:43 +0000 (18:19 +0000)]
IR: Drop uniquing when an MDNode Value operand is deleted

This is a fix for PR28697.

An MDNode can indirectly refer to a GlobalValue, through a
ConstantAsMetadata.  When the GlobalValue is deleted, the MDNode operand
is reset to `nullptr`.  If the node is uniqued, this can lead to a
hard-to-detect cache invalidation in a Metadata map that's shared across
an LLVMContext.

Consider:

 1. A map from Metadata* to `T` called RemappedMDs.
 2. A node that references a global variable, `!{i1* @GV}`.
 3. Insert `!{i1* @GV} -> SomeT` in the map.
 4. Delete `@GV`, leaving behind `!{null} -> SomeT`.

Looking up the generic and uninteresting `!{null}` gives you `SomeT`,
which is likely related to `@GV`.  Worse, `SomeT`'s lifetime may be tied
to the deleted `@GV`.

This occurs in practice in the shared ValueMap used since r266579 in the
IRMover.  Other code that handles more than one Module (with different
lifetimes) in the same LLVMContext could hit it too.

The fix here is a partial revert of r225223: in the rare case that an
MDNode operand is a ConstantAsMetadata (i.e., wrapping a node from the
Value hierarchy), drop uniquing if it gets replaced with `nullptr`.
This changes step #4 above to leave behind `distinct !{null} -> SomeT`,
which can't be confused with the generic `!{null}`.

In theory, this can cause some churn in the LLVMContext's MDNode
uniquing map when Values are being deleted.  However:

  - The number of GlobalValues referenced from uniqued MDNodes is
    expected to be quite small.  E.g., the debug info metadata schema
    only references GlobalValues from distinct nodes.

  - Other Constants have the lifetime of the LLVMContext, whose teardown
    is careful to drop references before deleting the constants.

As a result, I don't expect a compile time regression from this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277625 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agoAdding -verify-machineinstrs option to PowerPC tests
Ehsan Amiri [Wed, 3 Aug 2016 18:17:35 +0000 (18:17 +0000)]
Adding -verify-machineinstrs option to PowerPC tests

Currently we have a number of tests that fail with -verify-machineinstrs.
To detect this cases earlier we add the option to the testcases with the
exception of tests that will currently fail with this option. PR 27456 keeps
track of this failures.

No code review, as discussed with Hal Finkel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277624 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[Hexagon-ish] Add function to print cell map contents in bit tracker
Krzysztof Parzyszek [Wed, 3 Aug 2016 18:13:32 +0000 (18:13 +0000)]
[Hexagon-ish] Add function to print cell map contents in bit tracker

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277622 91177308-0d34-0410-b5e6-96231b3b80d8

8 years ago[CloneFunction] Don't crash if the value map doesn't hold something
David Majnemer [Wed, 3 Aug 2016 17:37:10 +0000 (17:37 +0000)]
[CloneFunction] Don't crash if the value map doesn't hold something

It is possible for the value map to not have an entry for some value
that has already been removed.

I don't have a testcase, this is fall-out from a buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277614 91177308-0d34-0410-b5e6-96231b3b80d8

8 years agouse local variables; NFC
Sanjay Patel [Wed, 3 Aug 2016 17:23:08 +0000 (17:23 +0000)]
use local variables; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277612 91177308-0d34-0410-b5e6-96231b3b80d8