platform/upstream/llvm.git
3 years ago[flang] Implement IPARITY, PARITY, and FINDLOC reductions
peter klausler [Tue, 20 Apr 2021 16:19:21 +0000 (09:19 -0700)]
[flang] Implement IPARITY, PARITY, and FINDLOC reductions

Define APIs for, and implement, these three more recently-introduced
standard reduction transformational intrinsic functions to the runtime.

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

3 years agoGet Section from resolved_addr in Target::ReadMemory
Jason Molenda [Tue, 20 Apr 2021 19:07:24 +0000 (12:07 -0700)]
Get Section from resolved_addr in Target::ReadMemory

Landing this fix for Augusto Noronha.  The code is getting the
Section from 'addr' passed in, but it may have been expressed as
a load address when it was created and Target::ReadMemory tries to
convert it to a Section+offset if that's now possible; use the
Section found from that cleanup if it exists.

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

3 years ago[libcxx] adds `iter_difference_t` and `iter_value_t`
Christopher Di Bella [Tue, 20 Apr 2021 18:56:08 +0000 (18:56 +0000)]
[libcxx] adds `iter_difference_t` and `iter_value_t`

Implements parts of:
    * P0896R4 The One Ranges Proposal

Depends on D99855.

Reviewed By: ldionne, #libc

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

3 years ago[Compiler-rt] Fix bug when considering CMake path returned by llvm-config.
Dan Liew [Tue, 20 Apr 2021 18:54:04 +0000 (11:54 -0700)]
[Compiler-rt] Fix bug when considering CMake path returned by llvm-config.

The previous check was wrong because it only checks that the LLVM CMake
directory exists. However, it's possible that the directory exists but
the `LLVMConfig.cmake` file does not. When this happens we would
incorectly try to include the non-existant file.

To fix this we make the check stricter by checking that the file
we want to include actually exists.

This is a follow up to fd28517d878e1d3d14f492ab659aabdf729fd331.

rdar://76870467

3 years agoRevert "Look through invertible recurrences in isKnownNonEqual"
Philip Reames [Tue, 20 Apr 2021 18:47:10 +0000 (11:47 -0700)]
Revert "Look through invertible recurrences in isKnownNonEqual"

This reverts commit be20eae25f50f5ef648aeefa1143e1c31e4410fc.  It appears to have caused a crash on a buildbot (https://lab.llvm.org/buildbot#builders/77/builds/5653).  Reverting while investigating.

3 years agoRearrange code to reduce diff for D99687 [nfc]
Philip Reames [Tue, 20 Apr 2021 18:38:56 +0000 (11:38 -0700)]
Rearrange code to reduce diff for D99687 [nfc]

Adding the switches to reduce diffs.  I'm about to split that into an lshr part and an ashr part, doing the NFC part first makes it easier to maintain both diffs.

3 years agoclang: Update libstdc++ issue workaround
Nathan Sidwell [Fri, 16 Apr 2021 19:34:30 +0000 (12:34 -0700)]
clang: Update libstdc++ issue workaround

Add some specificity to libstdc++ hack, perhaps we can remove it at a
later date.

3 years ago[tests] Expand coverage for D99687
Philip Reames [Tue, 20 Apr 2021 18:31:30 +0000 (11:31 -0700)]
[tests] Expand coverage for D99687

3 years ago[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication overflow...
Roman Lebedev [Tue, 20 Apr 2021 18:18:26 +0000 (21:18 +0300)]
[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication overflow check (PR48769)

We already had support for it's unsigned variant, so simply extend it
to also handle the signed variant.

Fixes https://bugs.llvm.org/show_bug.cgi?id=48769

3 years ago[NFC][InstCombine] Add tests for signed mul overflow check via mul-sdiv pattern ...
Roman Lebedev [Tue, 20 Apr 2021 18:06:55 +0000 (21:06 +0300)]
[NFC][InstCombine] Add tests for signed mul overflow check via mul-sdiv pattern (PR48769)

3 years ago[NFC][SCEV] Split getLosslessPtrToIntExpr out of getPtrToIntExpr()
Roman Lebedev [Tue, 20 Apr 2021 14:03:10 +0000 (17:03 +0300)]
[NFC][SCEV] Split getLosslessPtrToIntExpr out of getPtrToIntExpr()

3 years ago[NFC][LoopVectorize] Autogenerate check lines in pr45259.ll
Roman Lebedev [Mon, 19 Apr 2021 19:29:31 +0000 (22:29 +0300)]
[NFC][LoopVectorize] Autogenerate check lines in pr45259.ll

We might as well test all of the codegen here.

3 years ago[ELF] Don't set versionId on undefined weak lazy symbols
Fangrui Song [Tue, 20 Apr 2021 18:23:10 +0000 (11:23 -0700)]
[ELF] Don't set versionId on undefined weak lazy symbols

An unfetched lazy symbol (undefined weak) should be considered to have its
original versionId which is VER_NDX_GLOBAL, instead of the lazy symbol's
versionId. (The original versionId cannot be non-VER_NDX_GLOBAL because a
undefined versioned symbol is an error.)

The regression was introduced in D77280 when making version scripts work
with lazy symbols fetched by LTO calls.

Fix PR49915

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

3 years agoFix clang Visual Studio build instructions
Alessandro Vergani [Tue, 20 Apr 2021 18:02:48 +0000 (11:02 -0700)]
Fix clang Visual Studio build instructions

Change cd ..\.. to cd llvm-project (the former is probably a leftover
of the old svn instructions)

Committer: Adrian McCarthy <amccarth@google.com>

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

3 years ago[mlir] Make some functions public to use custom TypeIDs
Mathieu Fehr [Tue, 20 Apr 2021 17:49:30 +0000 (10:49 -0700)]
[mlir] Make some functions public to use custom TypeIDs

Currently, it is only possible to register an operation or a type
when the TypeID is defined at compile time. Same with InterfaceMaps
which can only be defined with compile-time defined interfaces.

With those changes, it is now possible to register types/operations
with custom TypeIDs. This is necessary to define new operations/types
at runtime.

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

3 years agoLook through invertible recurrences in isKnownNonEqual
Philip Reames [Tue, 20 Apr 2021 17:51:25 +0000 (10:51 -0700)]
Look through invertible recurrences in isKnownNonEqual

This extends the phi handling in isKnownNonEqual with a special case based on invertible recurrences. If we can prove the recurrence is invertible (which many common ones are), we can recurse through the start operands of the recurrence skipping the phi cycle.

(Side note: Instcombine currently does not push back through these cases. I will implement that in a follow up change w/separate review.)

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

3 years ago[libcxx][test] Construct non-empty containers in iterator's debug mode tests
Kristina Bessonova [Tue, 20 Apr 2021 17:50:29 +0000 (19:50 +0200)]
[libcxx][test] Construct non-empty containers in iterator's debug mode tests

The debug mode tests for map/set's iterators construct empty
containers, making the code after the first increment meaningless.
It's never executed since the tests exit earlier.

It doesn't seem to be intentional, so the patch makes the tests
to construct containers that include at least one element.

Reviewed By: curdeius, Quuxplusone

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

3 years ago[docs] Fix doxygen comments wrongly attached to the clang namespace
Nicolás Alvarez [Tue, 20 Apr 2021 17:49:27 +0000 (13:49 -0400)]
[docs] Fix doxygen comments wrongly attached to the clang namespace

Looking at the Doxygen-generated documentation for the clang namespace
currently shows several random comments from different parts of the
codebase. These are caused by:

- File doc comments that aren't marked with \file, so they're attached to
  the next declaration, which is usually "namespace clang {".
- Class doc comments placed before the namespace rather than before the
  class.

This commit fixes these comments. The generated doxygen documentation now
has proper docs for several classes and files, and the docs for the clang
namespace is now empty.

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

3 years ago[mlir][Standard][NFC] Fix op documentation
Javier Setoain [Tue, 20 Apr 2021 17:46:41 +0000 (10:46 -0700)]
[mlir][Standard][NFC] Fix op documentation

A couple of standard op examples that use an outdated syntax need an
update.

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

3 years ago[docs] Use make_unique in FrontendAction example
Nicolás Alvarez [Tue, 20 Apr 2021 17:47:16 +0000 (13:47 -0400)]
[docs] Use make_unique in FrontendAction example

The code example for "RecursiveASTVisitor based ASTFrontendActions"
was using unique_ptr<X>(new X) when creating the AST consumer; change
it to use make_unique instead. The main function of the same example
already used make_unique.

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

3 years agoUpdate tests checks, NFC.
Alexey Bataev [Tue, 20 Apr 2021 17:20:15 +0000 (10:20 -0700)]
Update tests checks, NFC.

3 years ago[llvm-objdump] Prefer positive boolean Verbose instead of negative NonVerbose. NFC
Fangrui Song [Tue, 20 Apr 2021 17:15:57 +0000 (10:15 -0700)]
[llvm-objdump] Prefer positive boolean Verbose instead of negative NonVerbose. NFC

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

3 years ago[test] Add a couple extra tests for recurrence matching in unreachable code
Philip Reames [Tue, 20 Apr 2021 17:07:58 +0000 (10:07 -0700)]
[test] Add a couple extra tests for recurrence matching in unreachable code

These are salvaged from D100004 as we took a different approach to the fix.

3 years ago[COST]Add a test for reverse shuffles cost on AArch64, NFC.
Alexey Bataev [Tue, 20 Apr 2021 17:00:05 +0000 (10:00 -0700)]
[COST]Add a test for reverse shuffles cost on AArch64, NFC.

3 years ago[test] Add a couple more tests for D99912
Philip Reames [Tue, 20 Apr 2021 16:56:47 +0000 (09:56 -0700)]
[test] Add a couple more tests for D99912

3 years agoTolerate missing debug info in the shared_ptr pretty printer.
Sterling Augustine [Fri, 16 Apr 2021 01:03:01 +0000 (18:03 -0700)]
Tolerate missing debug info in the shared_ptr pretty printer.

Certain fields of shared ptr have virtual functions and therefore
have their debug info homed in libc++. But if libc++ wasn't built
with debug info, the pretty printer would fail.

This patch makes the pretty printer tolerate such conditions and
updates the test harness.

This patch significantly reworks a previous attempt.

This addresses https://bugs.llvm.org/show_bug.cgi?id=48937

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

3 years ago[tests] Update per review comment on D99912
Philip Reames [Tue, 20 Apr 2021 16:41:41 +0000 (09:41 -0700)]
[tests] Update per review comment on D99912

(I'd copy and pasted the wrong test before tweaking, as a result, it wasn't a very good negative test.)

3 years ago[libcxx][doc] Use Phabricator links.
Mark de Wever [Tue, 20 Apr 2021 16:26:14 +0000 (18:26 +0200)]
[libcxx][doc] Use Phabricator links.

Use a link to the Phabricator review in the patch column.

Reviewed By: zoecarver, cjdb, #libc

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

3 years ago[OpenMP] Add OpenMPOpt as a Module pass
Joseph Huber [Wed, 24 Mar 2021 14:11:32 +0000 (10:11 -0400)]
[OpenMP] Add OpenMPOpt as a Module pass

Summary:
This patch registers OpenMPOpt as a Module pass in addition to a CGSCC
pass. This is so certain optimzations that are sensitive to intact
call-sites can happen before inlining. The old `openmpopt` pass name is
changed to `openmp-opt-cgscc` and `openmp-opt` calls the Module pass.
The current module pass only runs a single check but will be expanded in
the future.

Reviewed By: jdoerfert

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

3 years ago[PhaseOrdering] Add second test case for PR36760
Simon Pilgrim [Tue, 20 Apr 2021 16:27:24 +0000 (17:27 +0100)]
[PhaseOrdering] Add second test case for PR36760

3 years agoSilence MSVC signed/unsigned comparison warning. NFCI.
Simon Pilgrim [Tue, 20 Apr 2021 16:19:15 +0000 (17:19 +0100)]
Silence MSVC signed/unsigned comparison warning. NFCI.

3 years ago[mlir] Pass AnalysisManager as optional parameter to analysis ctor, so it can request...
Butygin [Sat, 10 Apr 2021 16:38:11 +0000 (19:38 +0300)]
[mlir] Pass AnalysisManager as optional parameter to analysis ctor, so it can request any other analysis as dependency

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

3 years ago[clangd] Use dirty filesystem when performing cross file tweaks
Nathan James [Tue, 20 Apr 2021 16:13:44 +0000 (17:13 +0100)]
[clangd] Use dirty filesystem when performing cross file tweaks

Cross file tweaks can now use the dirty buffer contents easily when performing cross file effects.
This can be noted on the DefineOutline tweak, now working when the target file is unsaved

Reviewed By: sammccall

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

3 years ago[mlir][spirv] Support conversion of extract op from vector<1xT> type
thomasraoux [Tue, 20 Apr 2021 04:24:06 +0000 (21:24 -0700)]
[mlir][spirv] Support conversion of extract op from vector<1xT> type

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

3 years ago[PhaseOrdering] Add test case for PR36760
Simon Pilgrim [Tue, 20 Apr 2021 16:07:12 +0000 (17:07 +0100)]
[PhaseOrdering] Add test case for PR36760

Ensures that the correct sequence of simplifycfg/instcombine/sroa reduce the IR to just a icmp+select

3 years ago[X86][SSE] combineX86ShuffleChain - check if we're blending with zero into already...
Simon Pilgrim [Tue, 20 Apr 2021 15:50:02 +0000 (16:50 +0100)]
[X86][SSE] combineX86ShuffleChain - check if we're blending with zero into already zero elements

Add a SelectionDAG::MaskedElementsAreZero helper that wraps SelectionDAG::MaskedValueIsZero testing for entirely zero vector elements

3 years ago[SLP] Add detection of shuffled/perfect matching of tree entries.
Alexey Bataev [Tue, 20 Apr 2021 15:30:09 +0000 (08:30 -0700)]
[SLP] Add detection of shuffled/perfect matching of tree entries.

SLP supports perfect diamond matching for the vectorized tree entries
but do not support it for gathered entries and does not support
non-perfect (shuffled) matching with 1 or 2 tree entries. Patch adds
support for this matching to improve cost of the vectorized tree.

Reviewed By: RKSimon

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

3 years agofree(nullptr) does not violate the nofree specification
Philip Reames [Tue, 20 Apr 2021 16:06:28 +0000 (09:06 -0700)]
free(nullptr) does not violate the nofree specification

This fixes a subtle and nasty bug in my 86664638. The problem is that free(nullptr) is well defined (and common).

The specification for the nofree attributes talks about memory objects, and doesn't explicitly address null, but I think it's reasonable to assume that nofree doesn't disallow a call to free(nullptr). If it did, we'd have to prove nonnull on an argument to ever infer nofree which doesn't seem to be the intent.

This was found by Nuno and Alive2 over in https://reviews.llvm.org/D100141#2697374.

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

3 years ago[libc++] NFC: Normalize `#endif //` comment indentation
Louis Dionne [Tue, 20 Apr 2021 16:03:32 +0000 (12:03 -0400)]
[libc++] NFC: Normalize `#endif //` comment indentation

3 years agoGlobalISel: Defer register creation in handleAssignments
Matt Arsenault [Tue, 13 Apr 2021 01:40:23 +0000 (21:40 -0400)]
GlobalISel: Defer register creation in handleAssignments

This is currently built on top of the SelectionDAG call lowering, but
does not use it the same way. SelectionDAG passes legalized types to
the assignment functions, and the tablegenerated assignment functions
may change the value types expected for registers. This does not
change the types used, just moves the register creation to help fix
this in the future.

Defer the register creation until after all of the assignment
decisions have been made. This will also help have correct tail call
compatibility checking in a future change. Currently it does not work
as expected for any arguments split across multiple registers.

3 years ago[AMDGPU] Allow multiple uses of the same literal
Jay Foad [Thu, 8 Apr 2021 11:58:49 +0000 (12:58 +0100)]
[AMDGPU] Allow multiple uses of the same literal

In GFX10 VOP3 can have a literal, which opens up the possibility of two
operands using the same literal value, which is allowed and only counts
as one use of the constant bus.

AMDGPUAsmParser::validateConstantBusLimitations already knew about this
but SIInstrInfo::verifyInstruction did not.

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

3 years ago[AArch64] Bump apple-latest CPU alias to apple-a14.
Ahmed Bougacha [Fri, 16 Apr 2021 20:54:13 +0000 (13:54 -0700)]
[AArch64] Bump apple-latest CPU alias to apple-a14.

3 years ago[AArch64] Don't always override CPU for arm64e.
Ahmed Bougacha [Fri, 16 Apr 2021 20:59:08 +0000 (13:59 -0700)]
[AArch64] Don't always override CPU for arm64e.

This demotes the apple-a12 CPU selection for arm64e to just be the
last-resort default.  Concretely, this means:
- an explicitly-specified -mcpu will override the arm64e default;
  a user could potentially pick an invalid CPU that doesn't have
  v8.3a support, but that's not a major problem anymore
- arm64e-apple-macos (and variants) will pick apple-m1 instead of
  being forced to apple-a12.

3 years ago[AArch64] Add apple-m1 CPU, and default to it for macOS.
Ahmed Bougacha [Thu, 15 Apr 2021 02:34:55 +0000 (19:34 -0700)]
[AArch64] Add apple-m1 CPU, and default to it for macOS.

apple-m1 has the same level of ISA support as apple-a14,
so this is a straightforward mechanical change.  However, that
also means this inherits apple-a14's v8.5a+nobti quirkiness.

rdar://68287159

3 years ago[gn build] Port 120fa8293e22
LLVM GN Syncbot [Tue, 20 Apr 2021 15:33:43 +0000 (15:33 +0000)]
[gn build] Port 120fa8293e22

3 years ago[libc++][nfc] Move iterator_traits and related into __iterator/iterator_traits.h.
zoecarver [Mon, 19 Apr 2021 21:44:42 +0000 (14:44 -0700)]
[libc++][nfc] Move iterator_traits and related into __iterator/iterator_traits.h.

Based on D100682 and D99855.

(Note: I originally was going to just make this part of D99855, but I decided not to because this patch moves lots of unrelated code around, and I didn't want to make D99855 harder to review because of unrelated code-changes/moves.)

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

3 years agoGlobalISel: Check for powers of 2 for inverse funnel shift lowering
Matt Arsenault [Mon, 29 Mar 2021 21:26:49 +0000 (17:26 -0400)]
GlobalISel: Check for powers of 2 for inverse funnel shift lowering

This doesn't make a practical difference since it would only be broken
if a target actually had a legal non-power-of-2 inverse shift.

3 years ago[libcxx] makes `iterator_traits` C++20-aware
zoecarver [Tue, 20 Apr 2021 12:50:11 +0000 (08:50 -0400)]
[libcxx] makes `iterator_traits` C++20-aware

* adds `iterator_traits` specialisation that supports all expected
  member aliases except for `pointer`
* adds `iterator_traits` specialisations for iterators that meet the
  legacy iterator requirements but might lack multiple member aliases
* makes pointer `iterator_traits` specialisation require objects

Depends on D99854.

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

3 years agoRevert "[SLP] Add detection of shuffled/perfect matching of tree entries."
Alexey Bataev [Tue, 20 Apr 2021 15:29:07 +0000 (08:29 -0700)]
Revert "[SLP] Add detection of shuffled/perfect matching of tree entries."

This reverts commit daf6e18c55c2ac56bbf0f9de233fb2a1150ee331 to fix the
compiler crash.

3 years ago[ARM] Limit PerformExtractEltToVMOVRRD to when f64 is legal.
David Green [Tue, 20 Apr 2021 15:24:36 +0000 (16:24 +0100)]
[ARM] Limit PerformExtractEltToVMOVRRD to when f64 is legal.

The generic SoftFloatVectorExtract.ll test was failing when run on arm
machines, as it tries to create a f64 under soft float. Limit the
transform to when f64 is legal.

Also add a missing override, as reported in D100244.

3 years agoAMDGPU/GlobalISel: Fix uitofp/sitofp with non-power-of-2 integers
Matt Arsenault [Sat, 27 Mar 2021 15:14:15 +0000 (11:14 -0400)]
AMDGPU/GlobalISel: Fix uitofp/sitofp with non-power-of-2 integers

3 years agoEnsure target-multiversioning emits deferred declarations
Erich Keane [Tue, 20 Apr 2021 14:35:57 +0000 (07:35 -0700)]
Ensure target-multiversioning emits deferred declarations

As reported in PR50025, sometimes we would end up not emitting functions
needed by inline multiversioned variants. This is because we typically
use the 'deferred decl' mechanism to emit these.  However, the variants
are emitted after that typically happens.  This fixes that by ensuring
we re-run deferred decls after this happens. Also, the multiversion
emission is done recursively to ensure that MV functions that require
other MV functions to be emitted get emitted.

3 years agoGlobalISel: Restrict narrow scalar for fptoui/fptosi results
Matt Arsenault [Fri, 26 Mar 2021 21:29:36 +0000 (17:29 -0400)]
GlobalISel: Restrict narrow scalar for fptoui/fptosi results

This practically only works for the f16 case AMDGPU uses, not wider
types.

Fixes bug 49710 by failing legalization.

3 years agoMachineVerifier: Continue reporting errors for copies
Matt Arsenault [Wed, 31 Mar 2021 20:45:19 +0000 (16:45 -0400)]
MachineVerifier: Continue reporting errors for copies

This was skipping verification of later copies, but generally the
verifier tries to report as many things wrong as possible in the
function.

3 years ago[SLP] Add detection of shuffled/perfect matching of tree entries.
Alexey Bataev [Tue, 20 Apr 2021 14:27:32 +0000 (07:27 -0700)]
[SLP] Add detection of shuffled/perfect matching of tree entries.

SLP supports perfect diamond matching for the vectorized tree entries
but do not support it for gathered entries and does not support
non-perfect (shuffled) matching with 1 or 2 tree entries. Patch adds
support for this matching to improve cost of the vectorized tree.

Reviewed By: RKSimon

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

3 years ago[mlir][StandardToSPIRV] Add support for lowering std.xor on bool to SPIR-V
Hanhan Wang [Tue, 20 Apr 2021 14:34:32 +0000 (07:34 -0700)]
[mlir][StandardToSPIRV] Add support for lowering std.xor on bool to SPIR-V

std.xor ops on bool are lowered to spv.LogicalNotEqual. For Boolean values, xor
and not-equal are the same thing.

Reviewed By: antiagainst

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

3 years ago[gn build] reformat all gn files
Nico Weber [Tue, 20 Apr 2021 14:33:35 +0000 (10:33 -0400)]
[gn build] reformat all gn files

$ git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format

(and manually wrap two comments)

3 years ago[AArch64][SVE] Lower MULHU/MULHS nodes to umulh/smulh instructions
Bradley Smith [Tue, 13 Apr 2021 14:19:59 +0000 (15:19 +0100)]
[AArch64][SVE] Lower MULHU/MULHS nodes to umulh/smulh instructions

Mark MULHS/MULHU nodes as legal for both scalable and fixed SVE types,
and lower them to the appropriate SVE instructions.

Additionally now that the MULH nodes are legal, integer divides can be
expanded into a more performant code sequence.

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

3 years agoRevert "[SLP] Add detection of shuffled/perfect matching of tree entries."
Alexey Bataev [Tue, 20 Apr 2021 14:15:25 +0000 (07:15 -0700)]
Revert "[SLP] Add detection of shuffled/perfect matching of tree entries."

This reverts commit b232771acad6225574a2eaf9f860a0fed7ef0804 to fix
buildbots.

3 years ago[ARM] Create VMOVRRD from adjacent vector extracts
David Green [Tue, 20 Apr 2021 14:15:43 +0000 (15:15 +0100)]
[ARM] Create VMOVRRD from adjacent vector extracts

This adds a combine for extract(x, n); extract(x, n+1)  ->
VMOVRRD(extract x, n/2). This allows two vector lanes to be moved at the
same time in a single instruction, and thanks to the other VMOVRRD folds
we have added recently can help reduce the amount of executed
instructions. Floating point types are very similar, but will include a
bitcast to an integer type.

This also adds a shouldRewriteCopySrc, to prevent copy propagation from
DPR to SPR, which can break as not all DPR regs can be extracted from
directly.  Otherwise the machine verifier is unhappy.

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

3 years ago[flang][driver] Refactor methods for parsing options (nfc)
Andrzej Warzynski [Wed, 14 Apr 2021 11:42:11 +0000 (11:42 +0000)]
[flang][driver] Refactor methods for parsing options (nfc)

This is just a small update that makes sure that errors arising from
parsing command-line options are captured more visibly. Also, all
parsing methods will now consistently return either a bool ("may fail")
or void ("never fails").

An instance of `InputKind` coming from `-x` is added to
`FrontendOptions` rather then being returned from `ParseFrontendArgs`.
It's currently not used, but we will require it shortly. In particular,
once code-generation is available we will use it to differentiate
between LLVM IR and Fortran input. `FrontendOptions` is a very suitable
place to keep it.

This changes don't affect the error reporting in the driver. In this
respect these are non-functional-changes. However, it will simplify
things in the forthcoming patches in which we may need a better error
tracking/recovery mechanism.

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

3 years ago[SLP] Add detection of shuffled/perfect matching of tree entries.
Alexey Bataev [Tue, 20 Apr 2021 12:47:55 +0000 (05:47 -0700)]
[SLP] Add detection of shuffled/perfect matching of tree entries.

SLP supports perfect diamond matching for the vectorized tree entries
but do not support it for gathered entries and does not support
non-perfect (shuffled) matching with 1 or 2 tree entries. Patch adds
support for this matching to improve cost of the vectorized tree.

Reviewed By: RKSimon

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

3 years ago[AArch64][AsmParser] NFC: Remove unused ExtendOp struct
Cullen Rhodes [Tue, 20 Apr 2021 12:22:37 +0000 (12:22 +0000)]
[AArch64][AsmParser] NFC: Remove unused ExtendOp struct

Left over from 2625a993f926 when extend and shift were merged.

3 years agoFix PR46880: Fail CHECK-NOT with undefined variable
Thomas Preud'homme [Fri, 28 Aug 2020 10:30:01 +0000 (11:30 +0100)]
Fix PR46880: Fail CHECK-NOT with undefined variable

Currently a CHECK-NOT directive succeeds whenever the corresponding
match fails. However match can fail due to an error rather than a lack
of match, for instance if a variable is undefined. This commit makes match
error a failure for CHECK-NOT.

Reviewed By: jdenny

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

3 years ago[AMDGPU] Add TransVALU to gfx10
Sebastian Neubauer [Thu, 8 Apr 2021 15:22:32 +0000 (17:22 +0200)]
[AMDGPU] Add TransVALU to gfx10

Instructions on the transcendental unit are executed in parallel to the
normal VALU, so add this as an extra resource.

This doesn't seem to have any effect, but it should be more correct.

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

3 years ago[RISCV][NFC] Add tests for scalable-vector DAGCombiner improvements
Fraser Cormack [Tue, 20 Apr 2021 12:53:10 +0000 (13:53 +0100)]
[RISCV][NFC] Add tests for scalable-vector DAGCombiner improvements

These will all be improved by future patches.

3 years ago[AMDGPU] Use if instead of foreach in a few places. NFC.
Jay Foad [Tue, 20 Apr 2021 13:19:51 +0000 (14:19 +0100)]
[AMDGPU] Use if instead of foreach in a few places. NFC.

3 years ago[flang][nfc] Port 2 tests to use the new driver when enabled
Andrzej Warzynski [Fri, 16 Apr 2021 15:23:47 +0000 (15:23 +0000)]
[flang][nfc] Port 2 tests to use the new driver when enabled

This is similar to https://reviews.llvm.org/D100309, i.e. `%f18` is
replaced with `%flang_new`.

resolve105.f90 wasn't in tree when D100309 was worked on, so it's
updated here instead.

label14.f90 requires `-fsyntax-only`. I didn't notice that when
submitting D100309, hence updating it now instead. `-fsyntax-only` is
required to prevent `%f18` from calling an external compiler (which then
fails and returns a non-zero exit code).

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

3 years ago[libc++][ci] Re-split the CI pipeline to try and reduce load on more builders
Louis Dionne [Tue, 20 Apr 2021 12:35:39 +0000 (08:35 -0400)]
[libc++][ci] Re-split the CI pipeline to try and reduce load on more builders

3 years ago[MCA][LSUnit] Fix a potential use after free in the logic that updates memory groups.
Andrea Di Biagio [Tue, 20 Apr 2021 11:57:20 +0000 (12:57 +0100)]
[MCA][LSUnit] Fix a potential use after free in the logic that updates memory groups.

Make sure that the `CriticalMemoryInstruction` of a memory group is invalidated
if it references an already executed instruction.  This avoids a potential
use-after-free if the critical memory info becomes stale, and the value is
read after the instruction has executed.

3 years ago[PowerPC] Canonicalize shuffles on big endian targets as well
Nemanja Ivanovic [Tue, 20 Apr 2021 11:25:18 +0000 (06:25 -0500)]
[PowerPC] Canonicalize shuffles on big endian targets as well

Extend shuffle canonicalization and conversion of shuffles fed by vectorized
scalars to big endian subtargets. For big endian subtargets, loads and direct
moves of scalars into vector registers put the data in the correct element for
SCALAR_TO_VECTOR if the data type is 8 bytes wide. However, if the data type is
narrower, the value still ends up in the wrong place - althouth a different
wrong place than on little endian targets.

This patch extends the combine that keeps values where they are if they feed a
shuffle to big endian targets.

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

3 years ago[llvm-objdump] Add an llvm-otool tool
Nico Weber [Thu, 15 Apr 2021 14:55:22 +0000 (10:55 -0400)]
[llvm-objdump] Add an llvm-otool tool

This implements an LLVM tool that's flag- and output-compatible
with macOS's `otool` -- except for bugs, but from testing with both
`otool` and `xcrun otool-classic`, llvm-otool matches vanilla
otool's behavior very well already. It's not 100% perfect, but
it's a very solid start.

This uses the same approach as llvm-objcopy: llvm-objdump uses
a different OptTable when it's invoked as llvm-otool. This
is possible thanks to D100433.

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

3 years ago[ValueTypes] Fix sizes of v256i32 and v256f32 (8182 -> 8192)
Cullen Rhodes [Tue, 20 Apr 2021 11:31:43 +0000 (11:31 +0000)]
[ValueTypes] Fix sizes of v256i32 and v256f32 (8182 -> 8192)

3 years ago[AMDGPU] Use simpler alternatives to !foldl. NFC.
Jay Foad [Tue, 20 Apr 2021 11:37:16 +0000 (12:37 +0100)]
[AMDGPU] Use simpler alternatives to !foldl. NFC.

3 years ago[mlir][linalg] lower index operations during linalg to vector lowering.
Tobias Gysi [Tue, 20 Apr 2021 11:26:44 +0000 (11:26 +0000)]
[mlir][linalg] lower index operations during linalg to vector lowering.

The patch extends the vectorization pass to lower linalg index operations to vector code. It allocates constant 1d vectors that enumerate the indexes along the iteration dimensions and broadcasts/transposes these 1d vectors to the iteration space.

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

3 years ago[DAG] SelectionDAG.cpp - breakup if-else chains where each block returns. NFCI.
Simon Pilgrim [Tue, 20 Apr 2021 10:59:23 +0000 (11:59 +0100)]
[DAG] SelectionDAG.cpp - breakup if-else chains where each block returns. NFCI.

Match style guide that requests that if+return blocks are separate.

3 years agoFix Wdocumentation warning by consistently using '///' comment blocks. NFCI.
Simon Pilgrim [Tue, 20 Apr 2021 10:41:04 +0000 (11:41 +0100)]
Fix Wdocumentation warning by consistently using '///' comment blocks. NFCI.

3 years ago[mlir] test gather/scatter index vector of type index.
Tobias Gysi [Tue, 20 Apr 2021 09:49:06 +0000 (09:49 +0000)]
[mlir] test gather/scatter index vector of type index.

Test the vector to llvm lowering of index vectors with index element type.

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

3 years ago[lit, test] Fix test cancellation feature detection
Thomas Preud'homme [Thu, 1 Apr 2021 14:02:36 +0000 (15:02 +0100)]
[lit, test] Fix test cancellation feature detection

A lit feature guards tests for the lit timeout functionality because on
most system it depends on the availability of the psutil Python module.
However, that feature is defined based on the ability of the testing lit
to cancel test, which does not necessarily apply to the ability of the
tested lit.

In particular, RUN commands have a cleared PYTHONPATH and user site
packages are disabled. In the case where psutil is found by the testing
lit from one of those two source of python path, the tested lit would
not be able to find it, causing timeout tests to fail.

This commit fixes the issue by testing the ability to cancel tests in
the RUN command environment.

Reviewed By: yln

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

3 years agoclang-format: [JS] do not merge imports and exports.
Martin Probst [Mon, 19 Apr 2021 11:31:06 +0000 (13:31 +0200)]
clang-format: [JS] do not merge imports and exports.

Previously, clang-format would erroneously merge import and export
statements. These need to be kept separate, as the semantics differ.

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

3 years ago[C++, test] Fix typo in NSS* vars
Thomas Preud'homme [Sat, 3 Apr 2021 10:49:50 +0000 (11:49 +0100)]
[C++, test] Fix typo in NSS* vars

The NSS FileCheck variables at the end of the
CodeGenCXX/split-stacks.cpp clang testcase are off by 1, resulting in
the use of an undefined variable (NSS3). One of the CHECK-NOT is also
redundant because _Z8tnosplitIiEiv uses the same attribute as _Z3foov
without split stack. This commit fixes that.

Reviewed By: ChuanqiXu

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

3 years ago[AMDGPU] Re-arrange ds_read/ds_write ISel pattern for better readability.
hsmahesha [Tue, 20 Apr 2021 10:47:05 +0000 (16:17 +0530)]
[AMDGPU] Re-arrange ds_read/ds_write ISel pattern for better readability.

Reviewed By: foad

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

3 years ago[MemoryBuiltins] Added support for memalign
Dávid Bolvanský [Tue, 20 Apr 2021 10:38:55 +0000 (12:38 +0200)]
[MemoryBuiltins] Added support for memalign

memalign is older aligned_alloc.

3 years ago[Support] APInt.h - remove <algorithm> include. NFCI.
Simon Pilgrim [Tue, 20 Apr 2021 10:21:26 +0000 (11:21 +0100)]
[Support] APInt.h - remove <algorithm> include. NFCI.

Replace std::min use which should allow us to avoid including the <algorithm> header in every include of APInt.h.

3 years ago[CodeGen] CodeGenPassBuilder.h - remove unnecessary <string> include. NFCI.
Simon Pilgrim [Tue, 20 Apr 2021 09:43:45 +0000 (10:43 +0100)]
[CodeGen] CodeGenPassBuilder.h - remove unnecessary <string> include. NFCI.

We only use StringRef so include that.

3 years ago[RISCV] Refactor an optimization of addition with immediate
Ben Shi [Tue, 20 Apr 2021 10:04:25 +0000 (18:04 +0800)]
[RISCV] Refactor an optimization of addition with immediate

Reviewed By: craig.topper

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

3 years ago[AArch64] Constant fold sve_convert_from_svbool(zero) to zero
Joe Ellis [Thu, 15 Apr 2021 08:12:11 +0000 (08:12 +0000)]
[AArch64] Constant fold sve_convert_from_svbool(zero) to zero

Co-authored-by: Paul Walker <paul.walker@arm.com>
Differential Revision: https://reviews.llvm.org/D100463

3 years ago[AArch64][SVE][InstCombine] Replace last{a,b} intrinsics with extracts...
Joe Ellis [Fri, 16 Apr 2021 10:05:05 +0000 (10:05 +0000)]
[AArch64][SVE][InstCombine] Replace last{a,b} intrinsics with extracts...

when the predicate used by last{a,b} specifies a known vector length.

For example:
  aarch64_sve_lasta(VL1, D) -> extractelement(D, #1)
  aarch64_sve_lastb(VL1, D) -> extractelement(D, #0)

Co-authored-by: Paul Walker <paul.walker@arm.com>
Differential Revision: https://reviews.llvm.org/D100476

3 years ago[libcxx][test] Split off debug mode tests
Kristina Bessonova [Tue, 20 Apr 2021 09:58:41 +0000 (11:58 +0200)]
[libcxx][test] Split off debug mode tests

This continues the work started by @ldionne in 2908eb20ba7.

The debug mode tests from

- libcxx/containers/sequences/vector/
- libcxx/strings/basic.string/string.access/
- libcxx/strings/basic.string/string.iterators/

similarly contain two tests in every file making the second test never
run. The patch splits the tests into separate files.

Reviewed By: Quuxplusone, ldionne

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

3 years ago[ARM] Regenerate a couple of tests. NFC
David Green [Tue, 20 Apr 2021 09:54:41 +0000 (10:54 +0100)]
[ARM] Regenerate a couple of tests. NFC

3 years ago[mlir] Progressively lower vector to SCF
Matthias Springer [Tue, 20 Apr 2021 08:17:56 +0000 (17:17 +0900)]
[mlir] Progressively lower vector to SCF

Add a new ProgressiveVectorToSCF pass that lowers vector transfer ops to SCF by gradually unpacking one dimension at time. Unpacking stops at 1D, but can be configured to stop earlier, should the HW support (N>1)-d vectors.

The current implementation cannot handle permutation maps, masks, tensor types and unrolling yet. These will be added in subsequent commits. Once features are on par with VectorToSCF, this implementation will replace VectorToSCF.

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

3 years ago[mlir] Add patterns to lower Math operations to LLVM based libm calls.
Tres Popp [Tue, 13 Apr 2021 08:18:34 +0000 (10:18 +0200)]
[mlir] Add patterns to lower Math operations to LLVM based libm calls.

Some Math operations do not have an equivalent in LLVM. In these cases,
allow a low priority fallback of calling the libm functions. This is to
give functionality and is not a performant option.

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

3 years ago[Support] BinaryStreamReader.h - remove unnecessary <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 16:56:42 +0000 (17:56 +0100)]
[Support] BinaryStreamReader.h - remove unnecessary <string> include. NFCI.

We only use StringRef so include that.

3 years agoRe-land [GreedyRA ORE] Add Cost of spill locations into remark
Serguei Katkov [Tue, 20 Apr 2021 05:59:44 +0000 (12:59 +0700)]
Re-land [GreedyRA ORE] Add Cost of spill locations into remark

Re-land the patch with a fix of clang test.

Cost of spill location is computed basing on relative branch frequency
where corresponding spill/reload/copy are located.

While the number itself is highly depends on incoming IR,
the total cost can be used when do some changes in RA.

Revert "Revert "[GreedyRA ORE] Add Cost of spill locations into remark""
This reverts commit 680f3d6de79f7dd75ee0cda256a541d18e504a22.

3 years ago[RISCV] Fix missing emergency slots for scalable stack offsets
Fraser Cormack [Thu, 15 Apr 2021 16:02:20 +0000 (17:02 +0100)]
[RISCV] Fix missing emergency slots for scalable stack offsets

This patch adds an additional emergency spill slot to RVV code. This is
required as RVV stack offsets may require an additional register to compute.

This patch includes an optimization by @HsiangKai <kai.wang@sifive.com>
to reduce the number of registers required for the computation of stack
offsets from 3 to 2. Otherwise we'd need two additional emergency spill
slots.

Reviewed By: HsiangKai

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

3 years ago[LV] Let selectVectorizationFactor reason directly on VectorizationFactor.
Sander de Smalen [Mon, 19 Apr 2021 09:59:30 +0000 (10:59 +0100)]
[LV] Let selectVectorizationFactor reason directly on VectorizationFactor.

Rather than maintaining two separate values, a `float` for the per-lane
cost and a Width for the VF, maintain a single VectorizationFactor which
comprises the two and also removes the need for converting an integer value
to float.

This simplifies the query when asking if one VF is more profitable than
another when we want to extend this for scalable vectors (which may
require additional options to determine if e.g. a scalable VF of the
some cost, is more profitable than a fixed VF of the same cost).

The patch isn't entirely NFC because it also fixes an issue in
selectEpilogueVectorizationFactor, where the cost passed to ProfitableVFs
no longer truncates the floating-point cost from `float` to `unsigned` to
then perform the calculation on the truncated cost. It now does
a cost comparison with the correct precision.

Reviewed By: dmgreen

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

3 years ago[PowerPC] Use mtvsrdd to put callee-saved GPR into VSR
Qiu Chaofan [Tue, 20 Apr 2021 08:32:24 +0000 (16:32 +0800)]
[PowerPC] Use mtvsrdd to put callee-saved GPR into VSR

This patch exploits mtvsrdd instruction (available in ISA3.0+) to save
two callee-saved GPR registers into a single VSR, making it more
efficient.

Reviewed By: jsji, nemanjai

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

3 years ago[DAGCombiner] Support fold zero scalar vector.
Jun Ma [Tue, 20 Apr 2021 03:37:06 +0000 (11:37 +0800)]
[DAGCombiner] Support fold zero scalar vector.

This patch changes ISD::isBuildVectorAllZeros to
ISD::isConstantSplatVectorAllZeros which handles zero sclar vector.

TestPlan: check-llvm

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

3 years ago[AMDGPU] GCNDPPCombine: don't shrink V_ADD_CO_U32 if carry out is used
Jay Foad [Mon, 19 Apr 2021 13:48:20 +0000 (14:48 +0100)]
[AMDGPU] GCNDPPCombine: don't shrink V_ADD_CO_U32 if carry out is used

Don't shrink VOP3 instructions if there are any uses of a carry-out
operand, because the shrunken form of the instruction would write the
carry-out to vcc instead of to a virtual register.

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

3 years ago[X86][AMX] Verify illegal types or instructions for x86_amx.
Luo, Yuanke [Tue, 20 Apr 2021 07:52:29 +0000 (15:52 +0800)]
[X86][AMX] Verify illegal types or instructions for x86_amx.

This patch is related to https://reviews.llvm.org/D100032 which define
some illegal types or operations for x86_amx. There are no arguments,
arrays, pointers, vectors or constants of x86_amx.

Reviewed By: pengfei

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