1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
Commit Graph

213688 Commits

Author SHA1 Message Date
Philip Reames
25318785e3 Extract a helper for figuring out if an operator is invertible [nfc]
For use in an uncoming patch.  Left out the phi case (which could otherwise fit in this framework) as it would cause infinite recursion in said patch.  We can probably also leverage this in instcombine to ensure we keep the two sets of related analysis and transforms in sync.
2021-04-05 12:14:21 -07:00
Philip Reames
126765f727 [tests] Precommmit tests for reasoning about equality of recurrences 2021-04-05 12:14:05 -07:00
Craig Topper
ad7dfa3912 [RISCV] Move VSLIDE1UP_VX pattern out of a loop that includes FP types.
FP would need VFSLIDE1UP_VF which uses an FP register.
2021-04-05 12:05:54 -07:00
Ricky Taylor
fa9c348cc4 [M68k] Add support for Motorola literal syntax to AsmParser
These look like $00A0cf for hex and  %001010101 for binary. They are used in Motorola assembly syntax.

Differential Revision: https://reviews.llvm.org/D98519
2021-04-05 20:02:29 +01:00
Jennifer Yu
925535c5ef [OPENMP51]Initial support for nocontext clause.
Added basic parsing/sema/serialization support for the 'nocontext' clause.

Differential Revision: https://reviews.llvm.org/D99848
2021-04-05 11:45:49 -07:00
Nico Weber
03c7f6ee36 [gn build] (manually) port 0116d04d04f2 2021-04-05 14:12:58 -04:00
Tom Stellard
c476e3c118 Revert "llvm-shlib: Create object libraries for each component and link against them"
This reverts commit 43ceb74eb1a5801662419fb66a6bf0d5414f1ec5.

This caused some build failures: https://bugs.llvm.org/show_bug.cgi?id=49818
2021-04-05 10:46:19 -07:00
Tom Stellard
c0e85d9efc Revert "Fix build rules for LLVM_WITH_Z3 after D95727"
This reverts commit d66f9c4f1e83e69abf75f97cb5f8fd1dc9422357.

This was a follow up fix for 43ceb74eb1a5801662419fb66a6bf0d5414f1ec5, which
will be reverted.
2021-04-05 10:46:19 -07:00
Cyndy Ishida
eff160f3ab [TextAPI] move source code files out of subdirectory, NFC
TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a
need to seperate out TextAPI between formats.

Reviewed By: ributzka, int3, #lld-macho

Differential Revision: https://reviews.llvm.org/D99811
2021-04-05 10:24:42 -07:00
LLVM GN Syncbot
05484c625c [gn build] Port 9b3df78b4c2a 2021-04-05 17:21:14 +00:00
Ta-Wei Tu
aa38fab0ab [LoopFusion] Bails out if only the second candidate is guarded (PR48060)
If only the second candidate loop is guarded while the first one is not, fusioning
two loops might not be valid but this check is currently missing.

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

Reviewed By: sidbav

Differential Revision: https://reviews.llvm.org/D99716
2021-04-06 01:08:56 +08:00
Fraser Cormack
c549b5e763 [RISCV] Add support for bitcasts between scalars and fixed-length vectors
This patch supports bitcasts from scalar types to fixed-length vectors
and vice versa. It custom-lowers and custom-legalizes them to
EXTRACT_VECTOR_ELT/INSERT_VECTOR_ELT operations, using a single-element
vectors to hold the scalar where appropriate.

Previously, some of these would fail to select, others would be expanded
through stack loads and stores. Effort was made to ensure the codegen
avoids the stack for both legal and illegal scalar types.

Some of the codegen could be improved, but on first glance it looks like
a general optimization of EXTRACT_VECTOR_ELT when extracting an i64
element on RV32.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D99667
2021-04-05 17:21:55 +01:00
Sanjay Patel
023bb4eb4e [InstCombine] fix potential miscompile in select value equivalence
As shown in the example based on:
https://llvm.org/PR49832
...and the existing test, we can't substitute
a vector value because the equality compare
replacement that we are attempting requires
that the comparison is true for the entire
value. Vector select can be partly true/false.
2021-04-05 12:25:40 -04:00
Sanjay Patel
ec094e0dd0 [InstCombine] add test for miscompile from select value equivalence; NFC
The new test is reduced from:
https://llvm.org/PR49832
...but we already show a potential miscompile in the existing test too.
2021-04-05 12:25:40 -04:00
John Paul Adrian Glaubitz
eb59dc67d9 [M68k] Mark public functions with the LLVM_EXTERNAL_VISIBILITY macro
In 0dbcb3639451, most most target symbols were made hidden by default
with the public ones marked with LLVM_EXTERNAL_VISIBILITY. When the
M68k target was added, this particular change was forgotten so that
external tools cannot make use of the public M68k target functions
in libLLVM.so. Thus, add the missing LLVM_EXTERNAL_VISIBILITY macro
to all public target functions in the M68k backend.

Differential Revision: https://reviews.llvm.org/D99869
2021-04-05 09:24:30 -07:00
Fraser Cormack
e445bcb7b3 [RISCV] Expand scalable-vector truncstores and extloads
Caught in internal testing, these operations are assumed legal by
default, even for scalable vector types. Expand them back into separate
truncations and stores, or loads and extensions.

Also add explicit fixed-length vector tests for these operations, even
though they should have been correct already.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D99654
2021-04-05 17:03:45 +01:00
Alexey Bataev
1e67d9efd7 [SLP]Improve vectorization of the CmpInst instructions.
During vectorization better to postpone the vectorization of the CmpInst
instructions till the end of the basic block. Otherwise we may vectorize
it too early and may miss some vectorization patterns, like reductions.

Reworked part of D57059

Differential Revision: https://reviews.llvm.org/D99796
2021-04-05 06:22:51 -07:00
Paul C. Anagnostopoulos
8c9238aaa1 [TableGen] [docs] Correct a couple of mistakes; use 'true' and 'false' in examples
Differential Revision: https://reviews.llvm.org/D99800
2021-04-05 09:15:58 -04:00
Alex Orlov
dac2590aaa * NFC. Refactored DIPrinter for better support of new print styles.
This patch introduces a DIPrinter interface to implement by different output style printer implementations. DIPrinterGNU and DIPrinterLLVM implement the GNU and LLVM output style printing respectively. No functional changes.

This refactoring clarifies and simplifies the code, and makes a new output style addition easier.

Reviewed By: jhenderson, dblaikie

Differential Revision: https://reviews.llvm.org/D98994
2021-04-05 15:40:41 +04:00
Fraser Cormack
9ae8059434 [RISCV] Add a test showing incorrect codegen
This patch adds a test which shows how the compiler incorrectly sets the
size and alignment of a stack object used to indirectly pass vector
types to functions.

In the particular example, the test passes a <4 x i8> vector type to a
function and creates a stack object of size and alignment equal to 4
bytes. However, the code generated to set up that parameter has been
scalarized and stores each element as individual XLEN-sized values. Thus
on RV32 this stores 16 bytes and on RV64 32 bytes, both of which clobber
the stack. Similarly, the alignment is set up as the alignment
of the vector type, which is not necessarily the natural alignment of XLEN.

Reviewed By: luismarques

Differential Revision: https://reviews.llvm.org/D95025
2021-04-05 11:51:03 +01:00
Simon Pilgrim
bda128cecc [X86] Fold xor(zext(xor(x,c1)),c2) -> xor(zext(x),xor(zext(c1),c2))
Fixes PR47603 (second case) by extending rG89afec348dbd3e5078f176e978971ee2d3b5dec8
2021-04-05 11:40:37 +01:00
Simon Pilgrim
e9442d18f5 [X86] Add second PR47603 test case
We had coverage for the xor(trunc(xor(x,31)),31) case but not xor(zext(xor(x,31)),31)
2021-04-05 11:40:36 +01:00
Josh Berdine
5dc0418f1b [NFC][OCaml] Reformat to clean up following CAMLprim removal
The removal of CAMLprim left the code in need of an application of
clang-format. There are various other changes made by clang-format
which it seems ought to be rolled together into this diff.

Differential Revision: https://reviews.llvm.org/D99477
2021-04-05 10:55:08 +01:00
Josh Berdine
ed4db92995 [NFC][OCaml] Remove vestigial CAMLprim declarations
The CAMLprim macro has not been needed since OCaml 3.11, and is
defined to the empty string. This diff removes all instances of it.

Differential Revision: https://reviews.llvm.org/D99476
2021-04-05 10:55:08 +01:00
Josh Berdine
40174ef1d4 [OCaml] Omit unnecessary GC root registrations
The current code does not follow the simple interface to the OCaml GC,
where GC roots are registered conservatively, only initializing
allocations are performed, etc. This is intentional, as stated in the
opening file comments. On the other hand, the current code does
register GC roots in many situations where it is not strictly
necessary. This diff omits many of them.

Differential Revision: https://reviews.llvm.org/D99475
2021-04-05 10:55:07 +01:00
Josh Berdine
aa8b5d3539 [OCaml] Code simplification using string allocation functions
Using the `cstr_to_string` function that allocates and initializes an
OCaml `string` value enables simplifications in several cases. This
change also has the effect of avoiding calling `memcpy` on NULL
pointers even if only 0 bytes are to be copied.

Differential Revision: https://reviews.llvm.org/D99474
2021-04-05 10:55:07 +01:00
Josh Berdine
e4e2c88791 [OCaml] Code simplification using option allocation functions
Using the `caml_alloc_some` and `ptr_to_option` functions that
allocate OCaml `option` values enables simplifications in many
cases. These simplifications also result in avoiding unnecessary
double initialization in many cases, so yield a minor optimization as
well.

Also, change to avoid using the old unprefixed functions such as
`alloc_small` and instead use the current `caml_alloc_small`.

A few of the changed functions were slightly rewritten in the
early-return style.

Differential Revision: https://reviews.llvm.org/D99473
2021-04-05 10:55:07 +01:00
Josh Berdine
e6e781e15b [OCaml] Minor optimizations by avoiding double initialization
In several functions an OCaml block is allocated and no further OCaml
allocation functions (or other functions that might trigger allocation
or collection) are performed before the block is fully initialized. In
these cases, it is safe and slightly more efficient to allocate an
uninitialized block.

Also, the code does not become more complex after the non-initializing
allocation, since in the case that a non-small allocation is made, the
initial values stored are definitely not pointers to OCaml young
blocks, and so initializing via direct assignment is still safe. That
is, in general if `caml_alloc_small` is called, initializing it with
direct assignments is safe, but if `caml_alloc_shr` is
called (e.g. for a block larger than `Max_young_wosize`), then
`caml_initialize` should be called to inform the GC of a potential
major to minor pointer. But if the initial value is definitely not a
young OCaml block, direct assignment is safe.

Differential Revision: https://reviews.llvm.org/D99472
2021-04-05 10:55:07 +01:00
Josh Berdine
77f642517b [OCaml] Fix unsafe uses of Store_field
Using `Store_field` to initialize fields of blocks allocated with
`caml_alloc_small` is unsafe. The fields of blocks allocated by
`caml_alloc_small` are not initialized, and `Store_field` calls the
OCaml GC write barrier. If the uninitialized value of a field happens
to point into the OCaml heap, then it will e.g. be added to a conflict
set or followed and have what the GC thinks are color bits
changed. This leads to crashes or memory corruption.

This diff fixes a few (I think all) instances of this problem. Some of
these are creating option values. OCaml 4.12 has a dedicated
`caml_alloc_some` function for this, so this diff adds a compatible
function with a version check to avoid conflict. With that, macros for
accessing option values are also added.

Differential Revision: https://reviews.llvm.org/D99471
2021-04-05 10:55:07 +01:00
Max Kazantsev
cbd5d54fdf [Test] Auto-update checks in a test 2021-04-05 16:24:00 +07:00
Max Kazantsev
1c57db9b5f [Test] Split out new and old PM tests
This is to avoid sophistication of checks as the old and new PM behave
differently with fix patches.
2021-04-05 14:51:29 +07:00
Max Kazantsev
416d585661 [Test] Add tests for various scenarios of PRE of a loop load 2021-04-05 12:50:11 +07:00
Craig Topper
ce92d4df25 [RISCV] Use gorciw for i32 orc.b intrinsic when Zbp is enabled.
The W version of orc.b does not exist in Zbp so we need to use
gorci encoding. If we have Zbp, we can use gorciw which can avoid a
sext.w in some cases.
2021-04-04 17:14:28 -07:00
Roman Lebedev
92ea6fc135 [InstCombine] dropRedundantMaskingOfLeftShiftInput(): check that adding shift amounts doesn't overflow (PR49778)
This is identical to 781d077afb0ed9771c513d064c40170c1ccd21c9,
but for the other function.

For certain shift amount bit widths, we must first ensure that adding
shift amounts is safe, that the sum won't have an unsigned overflow.

Fixes https://bugs.llvm.org/show_bug.cgi?id=49778
2021-04-04 23:26:41 +03:00
Roman Lebedev
1455781b8c [NFC][InstCombine] Extract canTryToConstantAddTwoShiftAmounts() as helper 2021-04-04 23:26:41 +03:00
Roman Lebedev
47102557b7 [NFC][InstCombine] Add test for PR49778 2021-04-04 23:26:41 +03:00
Craig Topper
3a21bda938 [RISCV] Lower orc.b intrinsic to RISCVISD::GORCI.
This will allow us to share any future known bits, demaned bits,
or sign bits improvements.
2021-04-04 12:31:41 -07:00
Sanjay Patel
48efde6d81 [InstCombine] fold popcount of exactly one bit to shift
This is discussed in https://llvm.org/PR48999 ,
but it does not solve that request.

The difference in the vector test shows that some
other logic transform is limited to scalar types.
2021-04-04 11:43:49 -04:00
Sanjay Patel
3e08429cd1 [InstCombine] add tests for ctpop of power-of-2; NFC
PR48999
2021-04-04 11:43:49 -04:00
Nikita Popov
9f9d5e9617 [SimplifyCFG] Handle two equal cases in switch to select
When converting a switch with two cases and a default into a
select, also handle the denegerate case where two cases have the
same value.

Generate this case directly as

  %or = or i1 %cmp1, %cmp2
  %res = select i1 %or, i32 %val, i32 %default

rather than

  %sel1 = select i1 %cmp1, i32 %val, i32 %default
  %res = select i1 %cmp2, i32 %val, i32 %sel1

as InstCombine is going to canonicalize to the former anyway.
2021-04-04 17:27:28 +02:00
Nikita Popov
85b251be7d [SimplifyCFG] Add switch-to-select test with two equal cases (NFC)
We handle the case where we have two cases and a default all having
different values, but not the case where two cases happen to have
the same one.

The PhaseOrdering test is a particularly bad example where this
showed up.
2021-04-04 17:14:59 +02:00
Nikita Popov
63d16a0c1b [SimplifyCFG] Make test more robust (NFC)
These are supposed to test creation of a switch, so make sure
there is some actual code in the branches. Otherwise this could
be turned into a select instead.
2021-04-04 17:14:59 +02:00
Roman Lebedev
2fd2d6fc5a [llvm-exegesis] SnippetFile: do create source manager in MCContext
This way, once there's an error in the snippet file (like in the test),
llvm-exegesis won't crash with an assertion failure,
but print a nice diagnostic about the problem.
2021-04-04 15:58:39 +03:00
Nikita Popov
cf9fa4358d [CVP] Add more tests for select with overdefined operand (NFC)
Also check the case where one operand isn't constant, which isn't
handled right now, because the SPF code requires both operands
to be ranges.

Move the tests to directly check ranges rather than go through an
and, to make it more obvious that this has no relation to bitmasks.
2021-04-04 13:54:06 +02:00
Roman Lebedev
01ca731f88 [llvm-exegesis] Don't erroneously refuse to measure POPCNT instruction 2021-04-04 14:38:26 +03:00
Dimitry Andric
2e53058780 Don't check that std::pair is trivially copyable on FreeBSD
As FreeBSD already used libc++ before it changed its ABI, we still use
the non-trivially copyable version of std::pair, which used to be
exposed via `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR`, but more recently via
`_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR`.

Reviewed By: serge-sans-paille

Differential Revision: https://reviews.llvm.org/D99834
2021-04-04 13:13:56 +02:00
Nikita Popov
ceee5076bf [LVI] Don't bail on overdefined value in select
Even if one of the operands is overdefined, we may still produce
a non-overdefined result, e.g. due to a min/max operation. This
matches our handling elsewhere, e.g. for binary operators.

The slot poisoning comment refers to a much older LVI cache
implementation.
2021-04-04 11:11:01 +02:00
Nikita Popov
e64cb9e15c [CVP] Add test for and of min (NFC)
The and currently doesn't get optimized away because %a is
overdefined.
2021-04-04 11:11:01 +02:00
Craig Topper
7c97405cff [RISCV] Don't convert fshr/fshl to target specific FSL/FSR node if shift amount is a constant.
As long as it's a constant we can directly pattern match it
without any problems. It's only when it isn't a constant that
we need to add an AND.

In theory this should allow more target independent optimizations
to remain active.
2021-04-03 23:13:30 -07:00
Juneyoung Lee
4ab503c839 [InstCombine] Conditionally fold select i1 into and/or
This patch fixes llvm.org/pr49688 by conditionally folding select i1 into and/or:

```
select cond, cond2, false
->
and cond, cond2
```

This is not safe if cond2 is poison whereas cond isn’t.

Unconditionally disabling this transformation affects later pipelines that depend on and/or i1s.
To minimize its impact, this patch conservatively checks whether cond2 is an instruction that
creates a poison or its operand creates a poison.
This approach is similar to what InstSimplify's SimplifyWithOpReplaced is doing.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D99674
2021-04-04 14:11:28 +09:00