OSDN Git Service

android-x86/external-llvm.git
6 years ago[llvm-objdump] - Stop reporting bogus section IDs.
George Rimar [Wed, 18 Jul 2018 08:34:35 +0000 (08:34 +0000)]
[llvm-objdump] - Stop reporting bogus section IDs.

Imagine we have a file with few sections, and one of them is .foo
with index N != 0.

Problem is that when llvm-objdump is given a -section=.foo parameter
it lists .foo as a section at index 0. That makes impossible to write
test cases which needs to find the index of the particular section,
while ignoring dumping of others.

The patch fixes that.

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

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

6 years ago[llvm-readobj] - Teach tool to dump objects with >= SHN_LORESERVE of sections.
George Rimar [Wed, 18 Jul 2018 08:19:58 +0000 (08:19 +0000)]
[llvm-readobj] - Teach tool to dump objects with >= SHN_LORESERVE of sections.

http://www.sco.com/developers/gabi/2003-12-17/ch4.eheader.html

says that e_shnum and/or e_shstrndx may have special values if
"the number of sections is greater than or equal to SHN_LORESERVE" or
"the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00)"

Previously llvm-readobj was unable to dump such files, patch changes that.

I had to add a precompiled test case because it does not seem possible to
prepare a test using yaml2obj or llvm-mc (not clear how to make .shstrtab
to have index >= SHN_LORESERVE).

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

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

6 years agoRevert test changes part of "Revert "[InstCombine] Fold 'check for [no] signed trunca...
Roman Lebedev [Wed, 18 Jul 2018 08:15:13 +0000 (08:15 +0000)]
Revert test changes part of "Revert "[InstCombine] Fold 'check for [no] signed truncation' pattern""

We want the test to remain good anyway.
I think the fix is incoming.

This reverts part of commit rL337344.

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

6 years ago[AArch64][SVE] Asm: Support for integer MUL instructions.
Sander de Smalen [Wed, 18 Jul 2018 08:10:03 +0000 (08:10 +0000)]
[AArch64][SVE] Asm: Support for integer MUL instructions.

This patch adds the following instructions:
  MUL   - multiply vectors, e.g.
    mul z0.h, p0/m, z0.h, z1.h
        - multiply with immediate, e.g.
    mul z0.h, z0.h, #127

  SMULH - signed multiply returning high half, e.g.
    smulh z0.h, p0/m, z0.h, z1.h

  UMULH - unsigned multiply returning high half, e.g.
    umulh z0.h, p0/m, z0.h, z1.h

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

6 years ago[X86] Enable commuting of VUNPCKHPD to VMOVLHPS to enable load folding by using VMOVL...
Craig Topper [Wed, 18 Jul 2018 07:31:32 +0000 (07:31 +0000)]
[X86] Enable commuting of VUNPCKHPD to VMOVLHPS to enable load folding by using VMOVLPS with a modified address.

This required an annoying amount of tablegen multiclass changes to make only VUNPCKHPDZ128rr commutable.

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

6 years ago[X86] Add test case for missed opportunity to commute vunpckhpd to enable use of...
Craig Topper [Wed, 18 Jul 2018 07:31:30 +0000 (07:31 +0000)]
[X86] Add test case for missed opportunity to commute vunpckhpd to enable use of vmovlps to fold a load.

We do this transform for SSE, but not AVX or AVX512VL.

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

6 years ago[X86] Regenerate fma.ll checks using current version of the script which produces...
Craig Topper [Wed, 18 Jul 2018 07:08:28 +0000 (07:08 +0000)]
[X86] Regenerate fma.ll checks using current version of the script which produces different regular expressions on spills and reloads. NFC

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

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Wed, 18 Jul 2018 06:04:43 +0000 (06:04 +0000)]
[NFC] fix trivial typos in comments

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

6 years agoFix build failures from r337347, found by clang
Justin Hibbits [Wed, 18 Jul 2018 05:19:25 +0000 (05:19 +0000)]
Fix build failures from r337347, found by clang

* Delete a no-longer-used override, and mark the other
getRegisterTypeForCallingConv() as override.
* SPE only supports i32, not i64, as the internal type, so simply remove
the type check, so that DestReg and Opc are provably always set.

GCC 6.4 did not warn about either of the above.

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

6 years ago[X86] Remove patterns that mix X86ISD::MOVLHPS/MOVHLPS with v2i64/v2f64 types.
Craig Topper [Wed, 18 Jul 2018 05:10:53 +0000 (05:10 +0000)]
[X86] Remove patterns that mix X86ISD::MOVLHPS/MOVHLPS with v2i64/v2f64 types.

The X86ISD::MOVLHPS/MOVHLPS should now only be emitted in SSE1 only. This means that the v2i64/v2f64 types would be illegal thus we don't need these patterns.

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

6 years ago[X86] Generate v2f64 X86ISD::UNPCKL/UNPCKH instead of X86ISD::MOVLHPS/MOVHLPS for...
Craig Topper [Wed, 18 Jul 2018 05:10:51 +0000 (05:10 +0000)]
[X86] Generate v2f64 X86ISD::UNPCKL/UNPCKH instead of X86ISD::MOVLHPS/MOVHLPS for unary v2f64 {0,0} and {1,1} shuffles with SSE2.

I'm trying to restrict the MOVLHPS/MOVHLPS ISD nodes to SSE1 only. With SSE2 we can use unpcks. I believe this will allow some patterns to be cleaned up to require fewer bitcasts.

I've put in an odd isel hack to still select MOVHLPS instruction from the unpckh node to avoid changing tests and because movhlps is a shorter encoding. Ideally we'd do execution domain switching on this, but the operands are in the wrong order and are tied. We might be able to try a commute in the domain switching using custom code.

We already support domain switching for UNPCKLPD and MOVLHPS.

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

6 years agoIntroduce codegen for the Signal Processing Engine
Justin Hibbits [Wed, 18 Jul 2018 04:25:10 +0000 (04:25 +0000)]
Introduce codegen for the Signal Processing Engine

Summary:
The Signal Processing Engine (SPE) is found on NXP/Freescale e500v1,
e500v2, and several e200 cores.  This adds support targeting the e500v2,
as this is more common than the e500v1, and is in SoCs still on the
market.

This patch is very intrusive because the SPE is binary incompatible with
the traditional FPU.  After discussing with others, the cleanest
solution was to make both SPE and FPU features on top of a base PowerPC
subset, so all FPU instructions are now wrapped with HasFPU predicates.

Supported by this are:
* Code generation following the SPE ABI at the LLVM IR level (calling
conventions)
* Single- and Double-precision math at the level supported by the APU.

Still to do:
* Vector operations
* SPE intrinsics

As this changes the Callee-saved register list order, one test, which
tests the precise generated code, was updated to account for the new
register order.

Reviewed by: nemanjai
Differential Revision: https://reviews.llvm.org/D44830

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

6 years agoComplete the SPE instruction set patterns
Justin Hibbits [Wed, 18 Jul 2018 04:24:57 +0000 (04:24 +0000)]
Complete the SPE instruction set patterns

This is the lead-up to having SPE codegen.  Add the rest of the
instructions, along with MC tests.

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

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

6 years agoAdd PowerPC e500(v2) core scheduler and directives.
Justin Hibbits [Wed, 18 Jul 2018 04:24:49 +0000 (04:24 +0000)]
Add PowerPC e500(v2) core scheduler and directives.

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

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

6 years agoRevert "[InstCombine] Fold 'check for [no] signed truncation' pattern"
Bob Haarman [Wed, 18 Jul 2018 02:18:28 +0000 (02:18 +0000)]
Revert "[InstCombine] Fold 'check for [no] signed truncation' pattern"

This reverts r337190 (and a few follow-up commits), which caused the
Chromium build to fail. See
https://bugs.llvm.org/show_bug.cgi?id=38204 and
https://crbug.com/864832

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

6 years agoCodeGen: Don't create address significance table entries for thread-local variables.
Peter Collingbourne [Wed, 18 Jul 2018 00:21:40 +0000 (00:21 +0000)]
CodeGen: Don't create address significance table entries for thread-local variables.

The presence of these symbols in the symbol table can cause symbol type
mismatch errors (or undefined symbol errors on emulated TLS targets)
and they can't be ICF'd anyway.

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

6 years ago[NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy.
Puyan Lotfi [Wed, 18 Jul 2018 00:10:51 +0000 (00:10 +0000)]
[NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy.

Nest any classes not used outside of a file into anon. Nest any classes used
across files in llvm-objcopy into namespace llvm::objcopy.

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

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

6 years ago[X86] Remove the vector alignment requirement from the patterns added in r337320.
Craig Topper [Tue, 17 Jul 2018 23:26:20 +0000 (23:26 +0000)]
[X86] Remove the vector alignment requirement from the patterns added in r337320.

The resulting instruction will only load 64 bits so alignment isn't required.

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

6 years agoCodeGen: Add a target option for emitting .addrsig directives for all address-signifi...
Peter Collingbourne [Tue, 17 Jul 2018 22:40:08 +0000 (22:40 +0000)]
CodeGen: Add a target option for emitting .addrsig directives for all address-significant symbols.

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

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

6 years agoMC: Implement support for new .addrsig and .addrsig_sym directives.
Peter Collingbourne [Tue, 17 Jul 2018 22:17:18 +0000 (22:17 +0000)]
MC: Implement support for new .addrsig and .addrsig_sym directives.

Part of the address-significance tables proposal:
http://lists.llvm.org/pipermail/llvm-dev/2018-May/123514.html

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

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

6 years ago[LangRef] Clarify semantics of load metadata.
Eli Friedman [Tue, 17 Jul 2018 20:38:11 +0000 (20:38 +0000)]
[LangRef] Clarify semantics of load metadata.

We need to explicitly state what happens when an invariant promised by
load metadata is violated at runtime, since it's come up repeatedly.

It's possible we want to specify that the result of the load is poison
in some cases, rather than undefined behavior, if the constraint is
violated. That would allow preserving the metadata when the load is
hoisted, but doesn't allow propagating metadata based on control flow.
We currently do transforms based on control flow for nonnull metadata
(in PromoteMemToReg).

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

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

6 years ago[LangRef] nnan and ninf produce poison.
Eli Friedman [Tue, 17 Jul 2018 20:31:42 +0000 (20:31 +0000)]
[LangRef] nnan and ninf produce poison.

Clarify that violating nnan and ninf can lead to undefined behavior.
This allows more aggressive optimizations based on those assumptions.

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

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

6 years ago[LangRef] Clarify which fast-math flags affect fcmp.
Eli Friedman [Tue, 17 Jul 2018 20:28:31 +0000 (20:28 +0000)]
[LangRef] Clarify which fast-math flags affect fcmp.

nsz has no effect due to the way fcmp is defined; +0 and -0 compare
equal anyway. reassoc could have the obvious effect.

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

6 years ago[X86] Add patterns for folding full vector load into MOVHPS and MOVLPS with SSE1...
Craig Topper [Tue, 17 Jul 2018 20:16:18 +0000 (20:16 +0000)]
[X86] Add patterns for folding full vector load into MOVHPS and MOVLPS with SSE1 only.

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

6 years ago[X86] Add test case for missed opportunity to use MOVLPS on the SSE1 only targets.
Craig Topper [Tue, 17 Jul 2018 20:16:15 +0000 (20:16 +0000)]
[X86] Add test case for missed opportunity to use MOVLPS on the SSE1 only targets.

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

6 years ago[Demangle] Add missing header files
Fangrui Song [Tue, 17 Jul 2018 19:50:41 +0000 (19:50 +0000)]
[Demangle] Add missing header files

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

6 years agoAdd missing include.
Zachary Turner [Tue, 17 Jul 2018 19:48:46 +0000 (19:48 +0000)]
Add missing include.

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

6 years agoAdd some helper functions to the demangle utility classes.
Zachary Turner [Tue, 17 Jul 2018 19:42:29 +0000 (19:42 +0000)]
Add some helper functions to the demangle utility classes.

These are all methods that, while not currently used in the
Itanium demangler, are generally useful enough that it's
likely the itanium demangler could find a use for them.  More
importantly, they are all necessary for the Microsoft demangler
which is up and coming in a subsequent patch.  Rather than
combine these into a single monolithic patch, I think it makes
sense to commit this utility code first since it is very simple,
this way it won't detract from the substance of the MS demangler
patch.

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

6 years ago[InstCombine] Preserve debug value when simplifying cast-of-select
Vedant Kumar [Tue, 17 Jul 2018 18:08:36 +0000 (18:08 +0000)]
[InstCombine] Preserve debug value when simplifying cast-of-select

InstCombine has a cast transform that matches a cast-of-select:

  Orig = cast (Src = select Cond TV FV)

And tries to replace it with a select which has the cast folded in:

  NewSel = select Cond (cast TV) (cast FV)

The combiner does RAUW(Orig, NewSel), so any debug values for Orig would
survive the transform. But debug values for Src would be lost.

This patch teaches InstCombine to replace all debug uses of Src with
NewSel (taking care of doing any necessary DIExpression rewriting).

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

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

6 years agoRemove an errant piece of !dbg metadata from a test, NFC
Vedant Kumar [Tue, 17 Jul 2018 18:08:34 +0000 (18:08 +0000)]
Remove an errant piece of !dbg metadata from a test, NFC

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

6 years ago[x86/SLH] Flesh out the data-invariant instruction table a bit based on feedback...
Chandler Carruth [Tue, 17 Jul 2018 18:07:59 +0000 (18:07 +0000)]
[x86/SLH] Flesh out the data-invariant instruction table a bit based on feedback from Craig.

Summary:
The only thing he suggested that I've skipped here is the double-wide
multiply instructions. Multiply is an area I'm nervous about there being
some hidden data-dependent behavior, and it doesn't seem important for
any benchmarks I have, so skipping it and sticking with the minimal
multiply support that matches what I know is widely used in existing
crypto libraries. We can always add double-wide multiply when we have
clarity from vendors about its behavior and guarantees.

I've tried to at least cover the fundamentals here with tests, although
I've not tried to cover every width or permutation. I can add more tests
where folks think it would be helpful.

Reviewers: craig.topper

Subscribers: sanjoy, mcrosier, hiraditya, llvm-commits

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

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

6 years ago[llvm-mca][x86] Add extend, carry-flag and CMP instructions to general x86_64 resourc...
Simon Pilgrim [Tue, 17 Jul 2018 17:47:35 +0000 (17:47 +0000)]
[llvm-mca][x86] Add extend, carry-flag and CMP instructions to general x86_64 resource tests

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

6 years ago[llvm-mca][x86] Add MOVBE resource tests to all supporting targets
Simon Pilgrim [Tue, 17 Jul 2018 17:41:45 +0000 (17:41 +0000)]
[llvm-mca][x86] Add MOVBE resource tests to all supporting targets

SNB doesn't support MOVBE but the numbers in Generic (which use the SNB model) look sane.

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

6 years agoRevert rL337292 due to another MSVC STL problem.
Florian Hahn [Tue, 17 Jul 2018 17:12:50 +0000 (17:12 +0000)]
Revert rL337292 due to another MSVC STL problem.

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

6 years ago[llvm-mca][x86] Add BSWAP resource tests
Simon Pilgrim [Tue, 17 Jul 2018 17:10:47 +0000 (17:10 +0000)]
[llvm-mca][x86] Add BSWAP resource tests

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

6 years ago[WebAssembly] Update WebAssemblyLowerEmscriptenEHSjLj to handle separate compilation
Sam Clegg [Tue, 17 Jul 2018 16:40:03 +0000 (16:40 +0000)]
[WebAssembly] Update WebAssemblyLowerEmscriptenEHSjLj to handle separate compilation

Previously we were assuming whole program compilation. Now that
separate compilation is a thing we need to update this pass.
Firstly, it can no longer assert on the existence of malloc and free.
This functions might not be in the current translation unit.  If we
need them then we will generate not imports for them.

Secondly the global helper function we create should be marked as
weak since we will be generating a separate copy in each translation
unit.

Finally the names of the symbols used must be unique and fixed since
they need to agree across translation units.

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

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

6 years ago[X86] Remove some standalone patterns in favor of the patterns in the MOVLPD instruct...
Craig Topper [Tue, 17 Jul 2018 16:24:33 +0000 (16:24 +0000)]
[X86] Remove some standalone patterns in favor of the patterns in the MOVLPD instruction definitions.

Previously we passed 'null_frag' into the instruction definition. The multiclass is shared with MOVHPD which doesn't use null_frag. It turns out by passing X86Movsd it produces patterns equivalent to some standalone patterns.

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

6 years ago[llvm-mca][x86] Add displacement-only and additional scale=1 LEA tests
Simon Pilgrim [Tue, 17 Jul 2018 16:17:33 +0000 (16:17 +0000)]
[llvm-mca][x86] Add displacement-only and additional scale=1 LEA tests

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

6 years ago[llvm-mca][x86] Add LEA resource tests (PR32326)
Simon Pilgrim [Tue, 17 Jul 2018 16:13:29 +0000 (16:13 +0000)]
[llvm-mca][x86] Add LEA resource tests (PR32326)

Add llvm-mca tests demonstrating how LEA instructions are currently modelled. Once this is working on btver2 I'll copy the test file to the other target directories.

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

6 years ago[llvm-mca][docs] Revert mca internals docs.
Matt Davis [Tue, 17 Jul 2018 16:11:54 +0000 (16:11 +0000)]
[llvm-mca][docs] Revert mca internals docs.

We're going to work on this in a separate review focusing more on documenting
the View and probably removing some of the less-interesting/less-useful pieces.

This reverts r337219,337225

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

6 years ago[Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`.
Andrea Di Biagio [Tue, 17 Jul 2018 16:11:37 +0000 (16:11 +0000)]
[Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`.

Function `expandCheckImmOperand` should always check if the input machine
instruction is passed by reference before calling method `getOperand()` on it.

Found while working on a patch that relies on `expandCheckImmOperand` to expand
a scheduling predicate.

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

6 years ago[AArch64][SVE]: Integer multiply-add/subtract instructions.
Sander de Smalen [Tue, 17 Jul 2018 15:41:58 +0000 (15:41 +0000)]
[AArch64][SVE]: Integer multiply-add/subtract instructions.

This patch adds support for the following instructions:
  MLA  mul-add, writing addend       (Zda = Zda +   Zn * Zm)
  MLS  mul-sub, writing addend       (Zda = Zda +  -Zn * Zm)
  MAD  mul-add, writing multiplicant (Zdn =  Za +  Zdn * Zm)
  MSB  mul-sub, writing multiplicant (Zdn =  Za + -Zdn * Zm)

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

6 years agoRecommit r334887: [SmallSet] Add SmallSetIterator.
Florian Hahn [Tue, 17 Jul 2018 15:24:19 +0000 (15:24 +0000)]
Recommit r334887: [SmallSet] Add SmallSetIterator.

Spell out destructor, copy/move constructor and assignment operators for
MSVC STL, where set<T>::const_iterator is not trivially copy constructible.

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

6 years ago[Mips][FastISel] Fix handling of icmp with i1 type
Petar Jovanovic [Tue, 17 Jul 2018 14:57:46 +0000 (14:57 +0000)]
[Mips][FastISel] Fix handling of icmp with i1 type

The Mips FastISel back-end does not extend i1 values while lowering icmp.
Ensure that we bail into DAG ISel when handling this case.

Patch by Dragan Mladjenovic.

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

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

6 years ago[IPSCCP] Run Solve each time we resolved an undef in a function.
Florian Hahn [Tue, 17 Jul 2018 14:04:59 +0000 (14:04 +0000)]
[IPSCCP] Run Solve each time we resolved an undef in a function.

Once we resolved an undef in a function we can run Solve, which could
lead to finding a constant return value for the function, which in turn
could turn undefs into constants in other functions that call it, before
resolving undefs there.

Computationally the amount of work we are doing stays the same, just the
order we process things is slightly different and potentially there are
a few less undefs to resolve.

We are still relying on the order of functions in the IR, which means
depending on the order, we are able to resolve the optimal undef first
or not. For example, if @test1 comes before @testf, we find the constant
return value of @testf too late and we cannot use it while solving
@test1.

This on its own does not lead to more constants removed in the
test-suite, probably because currently we have to be very lucky to visit
applicable functions in the right order.

Maybe we manage to come up with a better way of resolving undefs in more
'profitable' functions first.

Reviewers: efriedma, mssimpso, davide

Reviewed By: efriedma, davide

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

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

6 years ago[AArch64][SVE] Asm: FP fused multiply-add/subtract instructions.
Sander de Smalen [Tue, 17 Jul 2018 13:58:46 +0000 (13:58 +0000)]
[AArch64][SVE] Asm: FP fused multiply-add/subtract instructions.

This patch adds support for the following instructions:

  FMLA    mul-add, writing addend                (Zda =  Zda +   Zn * Zm)
  FNMLA   negated mul-add, writing addend        (Zda = -Zda +  -Zn * Zm)

  FMLS    mul-sub, writing addend                (Zda =  Zda +  -Zn * Zm)
  FNMLS   negated mul-sub, writing addend        (Zda = -Zda +   Zn * Zm)

  FMAD    mul-add, writing multiplicant          (Zdn =  Za  +  Zdn * Zm)
  FNMAD   negated mul-add, writing multiplicant  (Zdn = -Za  + -Zdn * Zm)

  FMSB    mul-sub, writing multiplicant          (Zdn =  Za  + -Zdn * Zm)
  FNMSB   negated mul-sub, writing multiplicant  (Zdn = -Za  +  Zdn * Zm)

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

6 years ago[SLPVectorizer] Don't attempt horizontal reduction on pointer types (PR38191)
Simon Pilgrim [Tue, 17 Jul 2018 13:43:33 +0000 (13:43 +0000)]
[SLPVectorizer] Don't attempt horizontal reduction on pointer types (PR38191)

TTI::getMinMaxReductionCost typically can't handle pointer types - until this is changed its better to limit horizontal reduction to integer/float vector types only.

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

6 years agoMore fixes for subreg join failure in RegCoalescer
Tim Renouf [Tue, 17 Jul 2018 12:38:39 +0000 (12:38 +0000)]
More fixes for subreg join failure in RegCoalescer

Summary:
Part of the adjustCopiesBackFrom method wasn't correctly dealing with SubRange
intervals when updating.

2 changes. The first to ensure that bogus SubRange Segments aren't propagated when
encountering Segments of the form [1234r, 1234d:0) when preparing to merge value
numbers. These can be removed in this case.

The second forces a shrinkToUses call if SubRanges end on the copy index
(instead of just the parent register).

V2: Addressed review comments, plus MIR test instead of ll test

Subscribers: MatzeB, qcolombet, nhaehnle

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

Change-Id: I1d2b2b4beea802fce11da01edf71feb2064aab05

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

6 years ago[AArch64][SVE] Asm: Support for predicated FP operations (FP immediate)
Sander de Smalen [Tue, 17 Jul 2018 12:36:08 +0000 (12:36 +0000)]
[AArch64][SVE] Asm: Support for predicated FP operations (FP immediate)

This patch completes support for the following floating point
instructions that take FP immediates:
  FADD*  (addition)
  FSUB   (subtract)
  FSUBR  (subtract reverse form)
  FMUL*  (multiplication)
  FMAX*  (maximum)
  FMAXNM (maximum number)
  FMIN   (maximum)
  FMINNM (maximum number)

All operations are predicated and take a FP immediate operand,
e.g.

  fadd z0.h, p0/m, z0.h, #0.5
  fmin z0.s, p0/m, z0.s, #1.0
        ^___________^ (tied)

* Instructions added in a previous patch.

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

6 years ago[NFC][testcases] add testcases for folding srem whose operands are negatived.
Chen Zheng [Tue, 17 Jul 2018 12:31:54 +0000 (12:31 +0000)]
[NFC][testcases] add testcases for folding srem whose operands are negatived.

Finish same optimization for add instruction in D49216 and sdiv instruction in
D49382. This patch is for srem instruction.

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

6 years agoDon't assert that a size_t fits into 64bit.
Joerg Sonnenberger [Tue, 17 Jul 2018 12:30:34 +0000 (12:30 +0000)]
Don't assert that a size_t fits into 64bit.

Avoids tautological compare warnings on 32bit platforms.

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

6 years ago[LLVM-C] Fix name mangling on AggressiveInstCombine
whitequark [Tue, 17 Jul 2018 11:13:58 +0000 (11:13 +0000)]
[LLVM-C] Fix name mangling on AggressiveInstCombine

Similarly to rL336736, at least one more C API function does not
properly get declared as extern "C" due to a missing header, causing
name mangling and linking errors.

This patch fixes calls to LLVMAddAggressiveInstCombinerPass().

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

Reviewed By: whitequark

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

6 years ago[LLVM-C] Add target triple normalization to the C API.
whitequark [Tue, 17 Jul 2018 10:57:39 +0000 (10:57 +0000)]
[LLVM-C] Add target triple normalization to the C API.

rL333307 was introduced to remove automatic target triple
normalization when calling sys::getDefaultTargetTriple(), arguing
that users of the latter already called Triple::normalize()
if necessary. However, users of the C API currently have no way of
doing target triple normalization.

This patch introduces an LLVMNormalizeTargetTriple function to
the C API which wraps Triple::normalize() and can be used on
the result of LLVMGetDefaultTargetTriple to achieve the same effect.

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

Reviewed By: whitequark

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

6 years ago[llvm-objcopy] Run not with any python, but the python configured in lit.
Benjamin Kramer [Tue, 17 Jul 2018 10:30:56 +0000 (10:30 +0000)]
[llvm-objcopy] Run not with any python, but the python configured in lit.

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

6 years ago[AArch64][SVE] Asm: Support for predicated FP operations.
Sander de Smalen [Tue, 17 Jul 2018 09:48:57 +0000 (09:48 +0000)]
[AArch64][SVE] Asm: Support for predicated FP operations.

This patch adds support for the following floating point
instructions:
  FABD   (absolute difference)
  FADD   (addition)
  FSUB   (subtract)
  FSUBR  (subtract reverse form)
  FDIV   (divide)
  FDIVR  (divide reverse form)
  FMAX   (maximum)
  FMAXNM (maximum number)
  FMIN   (minimum)
  FMINNM (minimum number)
  FSCALE (adjust exponent)
  FMULX  (multiply extended)

All operations are predicated and binary form, e.g.

  fadd z0.h, p0/m, z0.h, z1.h
        ^___________^ (tied)

Supporting 16, 32 and 64-bit FP elements.

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

6 years ago[DAGCombiner] Call SimplifyDemandedVectorElts from EXTRACT_VECTOR_ELT
Simon Pilgrim [Tue, 17 Jul 2018 09:45:35 +0000 (09:45 +0000)]
[DAGCombiner] Call SimplifyDemandedVectorElts from EXTRACT_VECTOR_ELT

If we are only extracting vector elements via EXTRACT_VECTOR_ELT(s) we may be able to use SimplifyDemandedVectorElts to avoid unnecessary vector ops.

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

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

6 years agoFix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.
Simon Pilgrim [Tue, 17 Jul 2018 09:39:55 +0000 (09:39 +0000)]
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.

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

6 years ago[AArch64][SVE] Asm: Support for SPLICE instruction.
Sander de Smalen [Tue, 17 Jul 2018 08:52:45 +0000 (08:52 +0000)]
[AArch64][SVE] Asm: Support for SPLICE instruction.

The SPLICE instruction splices two vectors into one vector using a
predicate. It copies the active elements from the first vector, and
then fills the remaining elements with the low-numbered elements from
the second vector.

The instruction has the following form, e.g.

  splice z0.b, p0, z0.b, z1.b

for 8-bit elements. It also supports 16, 32 and
64-bit elements.

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

6 years ago[AArch64][SVE] Asm: Support for EXT instruction.
Sander de Smalen [Tue, 17 Jul 2018 08:39:48 +0000 (08:39 +0000)]
[AArch64][SVE] Asm: Support for EXT instruction.

This patch adds an instruction that allows extracting
a vector from a pair of vectors, given an immediate index
that describes the element position to extract from.

The instruction has the following assembly:
  ext z0.b, z0.b, z1.b, #imm

where #imm is an immediate between 0 and 255.

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

6 years ago[X86] Properly qualify some MOVSS/MOVSD patterns with OptSize.
Craig Topper [Tue, 17 Jul 2018 06:24:16 +0000 (06:24 +0000)]
[X86] Properly qualify some MOVSS/MOVSD patterns with OptSize.

These are integer versions of patterns that I already fixed for floating point.

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

6 years ago[Sparc] Do not depend on icc for ta 1
Daniel Cederman [Tue, 17 Jul 2018 05:49:33 +0000 (05:49 +0000)]
[Sparc] Do not depend on icc for ta 1

The ta instruction will always trap, regardless of the value
of the integer condition codes. TRAPri is marked as using icc,
so we cannot use a pattern for TRAPri to implement ta 1, as
verify-machineinstrs can complain that icc is not defined.
Instead we implement ta 1 the same way as ta 5.

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

6 years ago[X86] Add full set of patterns for turning ceil/floor/trunc/rint/nearbyint into rndsc...
Craig Topper [Tue, 17 Jul 2018 05:48:48 +0000 (05:48 +0000)]
[X86] Add full set of patterns for turning ceil/floor/trunc/rint/nearbyint into rndscale with loads, broadcast, and masking.

This amounts to pretty ridiculous number of patterns. Ideally we'd canonicalize the X86ISD::VRNDSCALE earlier to reuse those patterns. I briefly looked into doing that, but some strict FP operations could still get converted to rint and nearbyint during isel. It's probably still worthwhile to look into. This patch is meant as a starting point to work from.

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

6 years ago[X86] Add test cases for selecting floor/ceil/trunc/rint/nearbyint to rndscale with...
Craig Topper [Tue, 17 Jul 2018 05:48:46 +0000 (05:48 +0000)]
[X86] Add test cases for selecting floor/ceil/trunc/rint/nearbyint to rndscale with masking, loading, and broadcasting.

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

6 years ago[testcases] move testcases to right place - NFC
Chen Zheng [Tue, 17 Jul 2018 01:04:41 +0000 (01:04 +0000)]
[testcases] move testcases to right place - NFC

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

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

6 years ago[llvm-mca][docs] Add notes about cycle and resource callbacks. NFC.
Matt Davis [Mon, 16 Jul 2018 23:50:53 +0000 (23:50 +0000)]
[llvm-mca][docs] Add notes about cycle and resource callbacks. NFC.

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

6 years ago[X86] Add a missing FMA3 scalar intrinsic pattern.
Craig Topper [Mon, 16 Jul 2018 23:10:58 +0000 (23:10 +0000)]
[X86] Add a missing FMA3 scalar intrinsic pattern.

This allows us to use 231 form to fold an insertelement on the add input to the fma. There is technically no software intrinsic that can use this until AVX512F, but it can be manually built up from other intrinsics.

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

6 years ago[WebAssembly] Remove ELF file support.
Sam Clegg [Mon, 16 Jul 2018 23:09:29 +0000 (23:09 +0000)]
[WebAssembly] Remove ELF file support.

This support was partial and temporary.  Now that we have
wasm object file support its no longer needed.

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

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

6 years ago[Intrinsics] define funnel shift IR intrinsics + DAG builder support
Sanjay Patel [Mon, 16 Jul 2018 22:59:31 +0000 (22:59 +0000)]
[Intrinsics] define funnel shift IR intrinsics + DAG builder support

As discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2018-May/123292.html
http://lists.llvm.org/pipermail/llvm-dev/2018-July/124400.html

We want to add rotate intrinsics because the IR expansion of that pattern is 4+ instructions,
and we can lose pieces of the pattern before it gets to the backend. Generalizing the operation
by allowing 2 different input values (plus the 3rd shift/rotate amount) gives us a "funnel shift"
operation which may also be a single hardware instruction.

Initially, I thought we needed to define new DAG nodes for these ops, and I spent time working
on that (much larger patch), but then I concluded that we don't need it. At least as a first
step, we have all of the backend support necessary to match these ops...because it was required.
And shepherding these through the IR optimizer is the primary concern, so the IR intrinsics are
likely all that we'll ever need.

There was also a question about converting the intrinsics to the existing ROTL/ROTR DAG nodes
(along with improving the oversized shift documentation). Again, I don't think that's strictly
necessary (as the test results here prove). That can be an efficiency improvement as a small
follow-up patch.

So all we're left with is documentation, definition of the IR intrinsics, and DAG builder support.

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

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

6 years ago[NFC][llvm-objcopy] Make helper functions static
Puyan Lotfi [Mon, 16 Jul 2018 22:17:05 +0000 (22:17 +0000)]
[NFC][llvm-objcopy] Make helper functions static

Anywhere in tools/llvm-objcopy where functions or classes are not referenced
outside of a given file, we change things to make the function or class static
or put inside an anonymous namespace.

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

6 years ago[llvm-mca][docs] Initial description of mca internals. NFC
Matt Davis [Mon, 16 Jul 2018 21:42:58 +0000 (21:42 +0000)]
[llvm-mca][docs] Initial description of mca internals. NFC

This patch introduces a brief description of the components of MCA.  The main
focus is on Views.   This is a work in progress, and more descriptions will be
introduced later.  I want to flesh-out the Views section more and provide a
detailed description of eventing in MCA.  Eventually a brief code example of a
View should accompany the description.

Also, we should consider moving the MCA internals guide elsewhere at some point.

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

6 years agoAdd missing includes.
Zachary Turner [Mon, 16 Jul 2018 21:34:25 +0000 (21:34 +0000)]
Add missing includes.

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

6 years ago[LLVMDemangle] Move some utility classes to header files.
Zachary Turner [Mon, 16 Jul 2018 21:24:03 +0000 (21:24 +0000)]
[LLVMDemangle] Move some utility classes to header files.

In a followup I'm looking to add a Microsoft demangler.  Doing
so needs a lot of the same utility classes and feature test
macros which are already implemented in ItaniumDemangle.cpp.
So move all of these things into header files so that they
can be re-used by a new demangler.

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

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

6 years ago[NFC][InstCombine] Fine-tune 'check for [no] signed truncation' tests
Roman Lebedev [Mon, 16 Jul 2018 20:10:46 +0000 (20:10 +0000)]
[NFC][InstCombine] Fine-tune 'check for [no] signed truncation' tests

We are using i8 for these tests, and shifting by 4,
which is exactly the half of i8.

But as it is seen from the proofs https://rise4fun.com/Alive/mgu
KeptBits = bitwidth(%x) - MaskedBits,
so with using shifts by 4, we are not really testing that
we actually properly handle the other cases with shifts not by half...

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

6 years ago[llvm-objcopy] Add support for large indexes
Jake Ehrlich [Mon, 16 Jul 2018 19:48:52 +0000 (19:48 +0000)]
[llvm-objcopy] Add support for large indexes

This patch is an update of an older patch that never landed
(see here: https://reviews.llvm.org/D42516)

Recently various users have run into this issue and it just 100%
has to be solved at this point. The main difference in this patch
is that I use gunzip instead of unzip which should hopefully allow
tests to pass. Please review this as if it is a new patch however.
I found some issues along the way and made some minor modifications.

The binary used in this patch for testing (a zip file to make it small)
can be found here:
https://drive.google.com/file/d/1UjsnTO9edLttZibbr-2T1bJl92KEQFAO/view?usp=sharing

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

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

6 years ago[CodeGen] Fix inconsistent declaration parameter name
Fangrui Song [Mon, 16 Jul 2018 18:51:40 +0000 (18:51 +0000)]
[CodeGen] Fix inconsistent declaration parameter name

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

6 years ago[AMDGPU] [AMDGPU] Support a fdot2 pattern.
Farhana Aleen [Mon, 16 Jul 2018 18:19:59 +0000 (18:19 +0000)]
[AMDGPU] [AMDGPU] Support a fdot2 pattern.

Summary: Optimize fma((float)S0.x, (float)S1.x fma((float)S0.y, (float)S1.y, z))
                   -> fdot2((v2f16)S0, (v2f16)S1, (float)z)

Author: FarhanaAleen

Reviewed By: rampitec, b-sumner

Subscribers: AMDGPU

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

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

6 years ago[llvm] Change 2 instances of std::sort to llvm::sort
Mandeep Singh Grang [Mon, 16 Jul 2018 17:26:37 +0000 (17:26 +0000)]
[llvm] Change 2 instances of std::sort to llvm::sort

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

6 years ago[InstCombine] Fold 'check for [no] signed truncation' pattern
Roman Lebedev [Mon, 16 Jul 2018 16:45:42 +0000 (16:45 +0000)]
[InstCombine] Fold 'check for [no] signed truncation' pattern

Summary:
[[ https://bugs.llvm.org/show_bug.cgi?id=38149 | PR38149 ]]

As discussed in https://reviews.llvm.org/D49179#1158957 and later,
the IR for 'check for [no] signed truncation' pattern can be improved:
https://rise4fun.com/Alive/gBf
^ that pattern will be produced by Implicit Integer Truncation sanitizer,
https://reviews.llvm.org/D48958 https://bugs.llvm.org/show_bug.cgi?id=21530
in signed case, therefore it is probably a good idea to improve it.

Proofs for this transform: https://rise4fun.com/Alive/mgu
This transform is surprisingly frustrating.
This does not deal with non-splat shift amounts, or with undef shift amounts.
I've outlined what i think the solution should be:
```
  // Potential handling of non-splats: for each element:
  //  * if both are undef, replace with constant 0.
  //    Because (1<<0) is OK and is 1, and ((1<<0)>>1) is also OK and is 0.
  //  * if both are not undef, and are different, bailout.
  //  * else, only one is undef, then pick the non-undef one.
```

The DAGCombine will reverse this transform, see
https://reviews.llvm.org/D49266

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: JDevlieghere, rkruppe, llvm-commits

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

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

6 years ago[RegAlloc] Skip global splitting if the live range is huge and its spill is
Wei Mi [Mon, 16 Jul 2018 15:42:20 +0000 (15:42 +0000)]
[RegAlloc] Skip global splitting if the live range is huge and its spill is
trivially rematerializable.

We run into a case where machineLICM hoists a large number of live ranges
outside of a big loop because it thinks those live ranges are trivially
rematerializable. In regalloc, global splitting is tried out first for those
live ranges before they are spilled and rematerialized. Because the global
splitting algorithm is quadratic, increasing a lot of global splitting
candidates causes huge compile time increase (50s to 1400s on my local
machine when compiling a module).

However, we think for live ranges which are very large and are trivially
rematerialiable, it is better to just skip global splitting so as to save
compile time with little chance of sacrificing performance.  We uses the
segment size of live range to indirectly evaluate whether the global
splitting of the live range can introduce high cost, and use an option
as a knob to adjust the size limit threshold.

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

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

6 years agoRestore "[ThinLTO] Ensure we always select the same function copy to import"
Teresa Johnson [Mon, 16 Jul 2018 15:30:27 +0000 (15:30 +0000)]
Restore "[ThinLTO] Ensure we always select the same function copy to import"

This reverts commit r337081, therefore restoring r337050 (and fix in
r337059), with test fix for bot failure described after the original
description below.

In order to always import the same copy of a linkonce function,
even when encountering it with different thresholds (a higher one then a
lower one), keep track of the summary we decided to import.
This ensures that the backend only gets a single definition to import
for each GUID, so that it doesn't need to choose one.

Move the largest threshold the GUID was considered for import into the
current module out of the ImportMap (which is part of a larger map
maintained across the whole index), and into a new map just maintained
for the current module we are computing imports for. This saves some
memory since we no longer have the thresholds maintained across the
whole index (and throughout the in-process backends when doing a normal
non-distributed ThinLTO build), at the cost of some additional
information being maintained for each invocation of ComputeImportForModule
(the selected summary pointer for each import).

There is an additional map lookup for each callee being considered for
importing, however, this was able to subsume a map lookup in the
Worklist iteration that invokes computeImportForFunction. We also are
able to avoid calling selectCallee if we already failed to import at the
same or higher threshold.

I compared the run time and peak memory for the SPEC2006 471.omnetpp
benchmark (running in-process ThinLTO backends), as well as for a large
internal benchmark with a distributed ThinLTO build (so just looking at
the thin link time/memory). Across a number of runs with and without
this change there was no significant change in the time and memory.

(I tried a few other variations of the change but they also didn't
improve time or peak memory).

The new commit removes a test that no longer makes sense
(Transforms/FunctionImport/hotness_based_import2.ll), as exposed by the
reverse-iteration bot. The test depends on the order of processing the
summary call edges, and actually depended on the old problematic
behavior of selecting more than one summary for a given GUID when
encountered with different thresholds. There was no guarantee even
before that we would eventually pick the linkonce copy with the hottest
call edges, it just happened to work with the test and the old code, and
there was no guarantee that we would end up importing the selected
version of the copy that had the hottest call edges (since the backend
would effectively import only one of the selected copies).

Reviewers: davidxl

Subscribers: mehdi_amini, inglorion, llvm-commits

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

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

6 years ago[cfi-verify] Abort on unsupported targets
Joel Galenson [Mon, 16 Jul 2018 15:26:44 +0000 (15:26 +0000)]
[cfi-verify] Abort on unsupported targets

As suggested in the review for r337007, this makes cfi-verify abort on unsupported targets instead of producing incorrect results.  It also updates the design document to reflect this.

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

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

6 years ago[InstrSimplify] add testcases for fold sdiv if two operands are negatived and non...
Chen Zheng [Mon, 16 Jul 2018 15:06:42 +0000 (15:06 +0000)]
[InstrSimplify] add testcases for fold sdiv if two operands are negatived and non-overflow

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

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

6 years ago[x86/SLH] Completely rework how we sink post-load hardening past data
Chandler Carruth [Mon, 16 Jul 2018 14:58:32 +0000 (14:58 +0000)]
[x86/SLH] Completely rework how we sink post-load hardening past data
invariant instructions to be both more correct and much more powerful.

While testing, I continued to find issues with sinking post-load
hardening. Unfortunately, it was amazingly hard to create any useful
tests of this because we were mostly sinking across copies and other
loading instructions. The fact that we couldn't sink past normal
arithmetic was really a big oversight.

So first, I've ported roughly the same set of instructions from the data
invariant loads to also have their non-loading varieties understood to
be data invariant. I've also added a few instructions that came up so
often it again made testing complicated: inc, dec, and lea.

With this, I was able to shake out a few nasty bugs in the validity
checking. We need to restrict to hardening single-def instructions with
defined registers that match a particular form: GPRs that don't have
a NOREX constraint directly attached to their register class.

The (tiny!) test case included catches all of the issues I was seeing
(once we can sink the hardening at all) except for the NOREX issue. The
only test I have there is horrible. It is large, inexplicable, and
doesn't even produce an error unless you try to emit encodings. I can
keep looking for a way to test it, but I'm out of ideas really.

Thanks to Ben for giving me at least a sanity-check review. I'll follow
up with Craig to go over this more thoroughly post-commit, but without
it SLH crashes everywhere so landing it for now.

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

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

6 years ago[mips] Eliminate the usage of hasStdEnc in MipsPat.
Simon Atanasyan [Mon, 16 Jul 2018 13:52:41 +0000 (13:52 +0000)]
[mips] Eliminate the usage of hasStdEnc in MipsPat.

Instead, the pattern is tagged with the correct predicate when
it is declared. Some patterns have been duplicated as necessary.

Patch by Simon Dardis.

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

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

6 years ago[MIPS GlobalISel] Select instructions to load and store i32 on stack
Petar Jovanovic [Mon, 16 Jul 2018 13:29:32 +0000 (13:29 +0000)]
[MIPS GlobalISel] Select instructions to load and store i32 on stack

Add code for selection of G_LOAD, G_STORE, G_GEP, G_FRAMEINDEX and
G_CONSTANT. Support loads and stores of i32 values.

Patch by Petar Avramovic.

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

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

6 years ago[X86][AArch64][DAGCombine] Unfold 'check for [no] signed truncation' pattern
Roman Lebedev [Mon, 16 Jul 2018 12:44:10 +0000 (12:44 +0000)]
[X86][AArch64][DAGCombine] Unfold 'check for [no] signed truncation' pattern

Summary:

[[ https://bugs.llvm.org/show_bug.cgi?id=38149 | PR38149 ]]

As discussed in https://reviews.llvm.org/D49179#1158957 and later,
the IR for 'check for [no] signed truncation' pattern can be improved:
https://rise4fun.com/Alive/gBf
^ that pattern will be produced by Implicit Integer Truncation sanitizer,
https://reviews.llvm.org/D48958 https://bugs.llvm.org/show_bug.cgi?id=21530
in signed case, therefore it is probably a good idea to improve it.

But the IR-optimal patter does not lower efficiently, so we want to undo it..

This handles the simple pattern.
There is a second pattern with predicate and constants inverted.

NOTE: we do not check uses here. we always do the transform.

Reviewers: spatel, craig.topper, RKSimon, javed.absar

Reviewed By: spatel

Subscribers: kristof.beyls, llvm-commits

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

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

6 years ago[Sparc] Use the correct encoding for ta 3
Daniel Cederman [Mon, 16 Jul 2018 12:28:26 +0000 (12:28 +0000)]
[Sparc] Use the correct encoding for ta 3

Summary: The old encoding generated a "tn %g1 + 3" instruction instead
of the expected "ta 3".

Reviewers: venkatra, jyknight

Reviewed By: jyknight

Subscribers: fedor.sergeev, jrtc27, llvm-commits

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

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

6 years ago[Sparc] Use the names .rem and .urem instead of __modsi3 and __umodsi3
Daniel Cederman [Mon, 16 Jul 2018 12:22:08 +0000 (12:22 +0000)]
[Sparc] Use the names .rem and .urem instead of __modsi3 and __umodsi3

Summary: These are the names used in libgcc.

Reviewers: venkatra, jyknight, ekedaigle

Reviewed By: jyknight

Subscribers: joerg, fedor.sergeev, jrtc27, llvm-commits

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

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

6 years ago[Sparc] Generate ta 1 for the @llvm.debugtrap intrinsic
Daniel Cederman [Mon, 16 Jul 2018 12:16:53 +0000 (12:16 +0000)]
[Sparc] Generate ta 1 for the @llvm.debugtrap intrinsic

Summary: Software trap number one is the trap used for breakpoints
in the Sparc ABI.

Reviewers: jyknight, venkatra

Reviewed By: jyknight

Subscribers: fedor.sergeev, jrtc27, llvm-commits

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

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

6 years agoAvoid losing Hi part when expanding VAARG nodes on big endian machines
Daniel Cederman [Mon, 16 Jul 2018 12:14:17 +0000 (12:14 +0000)]
Avoid losing Hi part when expanding VAARG nodes on big endian machines

Summary:
If the high part of the load is not used the offset to the next element
will not be set correctly.

For example, on Sparc V8, the following code will read val2 from offset 4
instead of 8.

```
int val = __builtin_va_arg(va, long long);
int val2 = __builtin_va_arg(va, int);
```

Reviewers: jyknight

Reviewed By: jyknight

Subscribers: fedor.sergeev, jrtc27, llvm-commits

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

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

6 years ago[x86/SLH] Fix a bug where we would try to post-load harden non-GPRs.
Chandler Carruth [Mon, 16 Jul 2018 11:38:48 +0000 (11:38 +0000)]
[x86/SLH] Fix a bug where we would try to post-load harden non-GPRs.

Found cases that hit the assert I added. This patch factors the validity
checking into a nice helper routine and calls it when deciding to harden
post-load, and asserts it when doing so later.

I've added tests for the various ways of loading a floating point type,
as well as loading all vector permutations. Even though many of these go
to identical instructions, it seems good to somewhat comprehensively
test them.

I'm confident there will be more fixes needed here, I'll try to add
tests each time as I get this predicate adjusted.

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

6 years agoMSan: minor fixes, NFC
Alexander Potapenko [Mon, 16 Jul 2018 10:57:19 +0000 (10:57 +0000)]
MSan: minor fixes, NFC

 - remove an extra space after |ID| declaration
 - drop the unused |FirstInsn| parameter in getShadowOriginPtrUserspace()

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

6 years ago[AccelTable] Provide DWARF5AccelTableStaticData for dsymutil.
Jonas Devlieghere [Mon, 16 Jul 2018 10:52:27 +0000 (10:52 +0000)]
[AccelTable] Provide DWARF5AccelTableStaticData for dsymutil.

For dsymutil we want to store offsets in the accelerator table entries
rather than DIE pointers. In addition, we need a way to communicate
which CU a DIE belongs to. This patch provides support for both of these
issues.

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

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

6 years ago[x86/SLH] Extract another small helper function, add better comments and
Chandler Carruth [Mon, 16 Jul 2018 10:46:16 +0000 (10:46 +0000)]
[x86/SLH] Extract another small helper function, add better comments and
use better terminology. NFC.

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

6 years ago[AMDGPU][Waitcnt] Re-apply fix "comparison of integers of different signs" build...
Mark Searles [Mon, 16 Jul 2018 10:21:36 +0000 (10:21 +0000)]
[AMDGPU][Waitcnt] Re-apply fix "comparison of integers of different signs" build error"

Re-apply "[AMDGPU][Waitcnt] fix "comparison of integers of different signs" build error""
fe0a456510131f268e388c4a18a92f575c0db183 ), which was inadvertantly reverted via
2b2ee080f0164485562593b1b87291a48cea4a9a .

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

6 years ago[MSan] factor userspace-specific declarations into createUserspaceApi(). NFC
Alexander Potapenko [Mon, 16 Jul 2018 10:03:30 +0000 (10:03 +0000)]
[MSan] factor userspace-specific declarations into createUserspaceApi(). NFC

This patch introduces createUserspaceApi() that creates function/global
declarations for symbols used by MSan in the userspace.
This is a step towards the upcoming KMSAN implementation patch.

Reviewed at https://reviews.llvm.org/D49292

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

6 years agorun post-RA hazard recognizer pass late
Mark Searles [Mon, 16 Jul 2018 10:02:41 +0000 (10:02 +0000)]
run post-RA hazard recognizer pass late

Memory legalizer, waitcnt, and shrink  passes can perturb the instructions,
which means that the post-RA hazard recognizer pass should run after them.
Otherwise, one of those passes may invalidate the work done by the hazard
recognizer. Note that this has adverse side-effect that any consecutive
S_NOP 0's, emitted by the hazard recognizer, will not be shrunk into a
single S_NOP <N>. This should be addressed in a follow-on patch.

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

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

6 years agoRevert "[AMDGPU][Waitcnt] fix "comparison of integers of different signs" build error"
Mark Searles [Mon, 16 Jul 2018 10:02:40 +0000 (10:02 +0000)]
Revert "[AMDGPU][Waitcnt] fix "comparison of integers of different signs" build error"

This reverts commit fe0a456510131f268e388c4a18a92f575c0db183.

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

6 years ago[MemorySSAUpdater] Remove deleted trivial Phis from active workset
Alexandros Lamprineas [Mon, 16 Jul 2018 07:51:27 +0000 (07:51 +0000)]
[MemorySSAUpdater] Remove deleted trivial Phis from active workset

Bug fix for PR37808. The regression test is a reduced version of the
original reproducer attached to the bug report. As stated in the report,
the problem was that InsertedPHIs was keeping dangling pointers to
deleted Memory-Phis. MemoryPhis are created eagerly and sometimes get
zapped shortly afterwards. I've used WeakVH instead of an expensive
removal operation from the active workset.

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

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

6 years ago[X86] Merge the FR128 and VR128 regclass since they have identical spill and alignmen...
Craig Topper [Mon, 16 Jul 2018 06:56:09 +0000 (06:56 +0000)]
[X86] Merge the FR128 and VR128 regclass since they have identical spill and alignment characteristics.

This unfortunately requires a bunch of bitcasts to be added added to SUBREG_TO_REG, COPY_TO_REGCLASS, and instructions in output patterns. Otherwise tablegen seems to default to picking f128 and then we fail when something tries to get the register class for f128 which isn't always valid.

The test changes are because we were previously mixing fr128 and vr128 due to contrainRegClass finding FR128 first and passes like live range shrinking weren't handling that well.

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