418106 Commits

Author SHA1 Message Date
Craig Topper
ad94dfb9a0 [DAGCombiner][RISCV] Adjust (aext (and (trunc x), cst)) -> (and x, cst) to sext cst based on target preference
RISCV strong prefers i32 values be sign extended to i64. This combine
was always zero extending the constant using APInt methods.

This adjusts the code so that it calls getNode using ISD::ANY_EXTEND instead.
getNode will call TLI.isSExtCheaperThanZExt to decide how to handle
the constant.

Tests were copied from D121598 where I noticed that we were creating
constants that were hard to materialize.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D121650
2022-03-15 08:26:47 -07:00
Pavel Labath
be09f83760 Revert "[lldb/test] Make category-skipping logic "platform"-independent"
This reverts commit dddf4ce034a8e06cc1351492dceece3fa2344c14. It breaks
a couple of tests on macos.
2022-03-15 16:23:43 +01:00
Craig Topper
06c5d74090 [RISCV] Remove lowerSPLAT_VECTOR
This code handles fixed vector SPLAT_VECTOR, but is never called in
any tests.

We only form fixed vector splat vectors for vXi64 on RV32 as part
of DAGCombine. This will be type legalized to SPLAT_VECTOR_PARTS.
So the Custom handling for SPLAT_VECTOR is never needed.

This patch makes SPLAT_VECTOR for vXi64 'Legal' on RV32 so that
DAGCombine will create it, but there's no need for Custom handler.
It will still be type legalized to SPLAT_VECTOR_PARTS.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D121673
2022-03-15 08:22:13 -07:00
Alex Brachet
ae4b59f179 [libc] Fix exit not calling new handlers registered from a call to atexit in atexit handler 2022-03-15 15:18:41 +00:00
Alex Brachet
d7c920e1a0 [libc][BlockStore] Add back, pop_back and empty methods
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D121656
2022-03-15 15:11:57 +00:00
Yitzhak Mandelbaum
4633c02eb0 [clang][dataflow] Allow disabling built-in transfer functions for CFG terminators
Terminators are handled specially in the transfer functions so we need an
additional check on whether the analysis has disabled built-in transfer
functions.

Differential Revision: https://reviews.llvm.org/D121694
2022-03-15 15:10:32 +00:00
Sanjay Patel
598721f866 [InstCombine] try harder to propagate 'nsz' through fneg-of-select
This can be viewed as swapping the select arms:
https://alive2.llvm.org/ce/z/jUvFMJ
...so we don't have the 'nsz' problem with the more general fold.

This unlocks other folds for the motivating fabs example.
This was discussed in issue #38828.
2022-03-15 11:05:29 -04:00
Sanjay Patel
2d3593e668 [InstCombine] add tests for fneg-of-select with FMF; NFC 2022-03-15 11:05:29 -04:00
Louis Dionne
f6fd1c1438 [libc++] Overhaul all tests for assertions and debug mode
Prior to this patch, there was no distinction between tests that check
basic assertions and tests that check full-fledged iterator debugging
assertions. Both were disabled when support for the debug mode is not
provided in the dylib, which is stronger than it needs to be.

Furthermore, all of the tests using "debug_macros.h" that contain more
than one assertion in them were broken -- any code after the first
assertion would never be executed.

This patch refactors all of our assertion-related tests to:
1. Be enabled whenever they can, i.e. basic assertions tests are run
   even when the debug mode is disabled.
2. Use the superior `check_assertion.h` (previously `debug_mode_helper.h`)
   instead of `debug_macros.h`, which allows multiple assertions in the
   same program.
3. Coalesce some tests into the same file to make them more readable.
4. Use consistent naming for test files -- no more db{1,2,3,...,10} tests.

This is a large but mostly mechanical patch.

Differential Revision: https://reviews.llvm.org/D121462
2022-03-15 10:56:34 -04:00
Simon Moll
6ac3d8ef9c [VE] strided v256.23 isel and tests
ISel for experimental.vp.strided.load|store for v256.32 types via
lowering to vvp_load|store SDNodes.

Reviewed By: kaz7

Differential Revision: https://reviews.llvm.org/D121616
2022-03-15 15:29:19 +01:00
Sam Carroll
541d89b02c [mlir] Fix --convert-func-to-llvm=emit-c-wrappers argument and result attribute handling
When using `--convert-func-to-llvm=emit-c-wrappers` the attribute arguments of the wrapper would not be created correctly in some cases.
This patch fixes that and introduces a set of tests for (hopefully) all corner cases.

See https://github.com/llvm/llvm-project/issues/53503

Author: Sam Carroll <sam.carroll@lmns.com>
Co-Author: Laszlo Kindrat <laszlo.kindrat@lmns.com>

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D119895
2022-03-15 15:29:43 +01:00
Tue Ly
64af346b18 [libc] Implement expm1f function that is correctly rounded for all rounding modes.
Implement expm1f function that is correctly rounded for all rounding modes.  This is based on expf implementation.

From exhaustive testings, using expf implementation, and subtract 1.0 before rounding the final result to single precision
gives correctly rounded results for all |x| > 2^-4 with 1 exception.  When |x| < 2^-25, we use x + x^2 (implemented with a
single fma).  And for 2^-25 <= |x| <= 2^-4, we use a single degree-8 minimax polynomial generated by Sollya.

Reviewed By: sivachandra, zimmermann6

Differential Revision: https://reviews.llvm.org/D121574
2022-03-15 10:24:56 -04:00
Simon Pilgrim
7e4cf582cf [InstCombine] Add general constant support to eq/ne icmp(add(X,C1),add(Y,C2)) -> icmp(add(X,C1-C2),Y) fold
A further extension for Issue #32161

For eq/ne comparisons - the sign mismatch and bounds constraints are redundant, so if the that fold fails, fallback and just fold the constants directly.

https://alive2.llvm.org/ce/z/cdodNQ

The loop rotation test change looks mostly benign - the backend doesn't seem to suffer? https://gcc.godbolt.org/z/dErMY78To

Differential Revision: https://reviews.llvm.org/D121551
2022-03-15 14:17:38 +00:00
Simon Pilgrim
1df20fa8f5 [JITLink] Fix -Wparentheses warning in R_RISCV_SUB6 case.
Perform the mask inside parentheses before applying the offset
2022-03-15 14:13:28 +00:00
Ties Stuij
352453569b [AARCH64] ssbs should be enabled by default for cortex-x1, cortex-x1c, cortex-a77
Reviewed By: amilendra

Differential Revision: https://reviews.llvm.org/D121206
2022-03-15 13:44:20 +00:00
Arnamoy Bhattacharyya
0e9198c3e9 [MLIR][OpenMP] Add support for basic SIMD construct
Patch adds a new operation for the SIMD construct.  The op is designed to be very similar to the existing `wsloop` operation, so that the `CanonicalLoopInfo` of `OpenMPIRBuilder` can be used.

Reviewed By: shraiysh

Differential Revision: https://reviews.llvm.org/D118065
2022-03-15 09:41:04 -04:00
Steven Wu
e168513aed [ASAN] Fix darwin-interface test
Fix darwin interface test after D121464. asan_rtl_x86_64.S is not
available on Darwin.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D121636
2022-03-15 06:14:07 -07:00
LLVM GN Syncbot
c55b4c276f [gn build] Port 7262eacd4199 2022-03-15 13:08:09 +00:00
Wael Yehia
ed4c03afac Revert "Load pass plugins during option processing, so that plugin options are registered and live."
This reverts commit 5e8700ce8bf58bdf0a59eef99c85185a74177555.
2022-03-15 13:02:37 +00:00
Simon Pilgrim
7262eacd41 Revert rG9c542a5a4e1ba36c24e48185712779df52b7f7a6 "Lower @llvm.global_dtors using __cxa_atexit on MachO"
Mane of the build bots are complaining: Unknown command line argument '-lower-global-dtors'
2022-03-15 13:01:35 +00:00
Pavel Labath
991dc4b4e0 Remove a top-level "using namespace" in TargetTransformInfoImpl.h
Avoids polluting the namespace of all files including the header.
2022-03-15 13:49:20 +01:00
Wael Yehia
5e8700ce8b Load pass plugins during option processing, so that plugin options are registered and live. 2022-03-15 12:43:49 +00:00
Pavel Labath
dddf4ce034 [lldb/test] Make category-skipping logic "platform"-independent
The decision which categories are relevant for a particular test run
happen very early in the test setup process. They use the SBPlatform
object to determine which categories should be skipped. The platform
object created for this purpose transcends individual test runs.

This setup is not compatible with the direction discussed in
<https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>
-- when platform objects are tied to a specific (SB)Debugger, they need
to be created alongside it, which currently happens in the test setUp
method.

This patch is the first step in that direction -- it rewrites the
category skipping logic to avoid depending on a global SBPlatform
object. Fortunately, the skipping logic is fairly simple (and I believe
it outght to stay that way) and mainly consists of comparing the
platform name against some hardcoded lists. This patch bases this
comparison on the platform name instead of the os part of the triple (as
reported by the platform).

Differential Revision: https://reviews.llvm.org/D121605
2022-03-15 13:38:13 +01:00
Florian Hahn
a9772a7148
[BasicAA] Add test showing incorrect noalias result with wrapping.
@mul_may_overflow_var_nonzero_minabsvarindex_one_index shows BasicAA
incorrectly determining noalias for (%gep.917, i8* %gep.idx).
If %v == 10581764700698480926, %idx == 917 and the GEPs alias.
https://alive2.llvm.org/ce/z/yzDgnn
2022-03-15 12:32:07 +00:00
Matthias Springer
39ec46bd83 [mlir][bufferize] Extract buffer hoisting into separate function
This improves the modularity of the bufferization.

From now on, all ops that do not implement BufferizableOpInterface are considered hoisting barriers. Previously, all ops that do not implement the interface were not considered barriers and such ops had to be marked as barriers explicitly. This was unsafe because we could've hoisted across unknown ops where it was not safe to hoist.

As a side effect, this allows for cleaning up AffineBufferizableOpInterfaceImpl. This build unit no longer needed and can be deleted.

Differential Revision: https://reviews.llvm.org/D121519
2022-03-15 21:25:03 +09:00
Marek Kurdej
3227aa3aa8 [clang-format] Correctly format variable templates.
Fixes https://github.com/llvm/llvm-project/issues/54257.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121456
2022-03-15 13:16:56 +01:00
Simon Pilgrim
f591231cad [X86] combineSelect - canonicalize (vXi1 bitcast(iX Cond)) with combineToExtendBoolVectorInReg before legalization
This replaces the attempt in 20af71f8ec47319d375a871db6fd3889c2487cbd to use combineToExtendBoolVectorInReg to create X86ISD::BLENDV masks directly, instead we use it to canonicalize the iX bitcast to a sign-extended mask and then truncate it back to vXi1 prior to legalization breaking it apart.

Fixes #53760
2022-03-15 12:16:11 +00:00
Marek Kurdej
e60defb931 [clang-format] Add regression tests for function ref qualifiers on operator definition. NFC.
Fixes https://github.com/llvm/llvm-project/issues/54374.
2022-03-15 12:58:08 +01:00
Florian Hahn
5c4d64eb0d
[LV] Make reduction-order.ll test independent of instruction naming.
Also update test to not use branch on undef.
2022-03-15 11:13:18 +00:00
Dmitry Makogon
361034ba78 [NFC] Add LazyValueInfo::clear method
This method just calls LazyValueInfoImpl::clear
2022-03-15 17:52:50 +07:00
Marek Kurdej
126b37a713 [clang-format] Correctly recognize arrays in template parameter list.
Fixes https://github.com/llvm/llvm-project/issues/54245.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121584
2022-03-15 11:33:13 +01:00
Ivan Butygin
9f864a5447 [mlir][gpu] Introduce gpu.global_id op
Introduce OpenCL-style global_id op and corresponding spirv lowering.

Differential Revision: https://reviews.llvm.org/D121548
2022-03-15 13:25:50 +03:00
Ivan Butygin
7b0e041df8 [mlir][spirv] Add AssumeTrueKHROp
Differential Revision: https://reviews.llvm.org/D121601
2022-03-15 13:03:45 +03:00
Matthias Springer
05e0495f1d [mlir][bufferize][NFC] Deallocate all buffers at the end of bufferization
This makes bufferization more modular. This is in preparation of future refactorings.

Differential Revision: https://reviews.llvm.org/D121362
2022-03-15 17:53:53 +09:00
Nikita Popov
875782bd9e [OpenMPOpt] Avoid pointer element type access during region merging
Hardcode the function type as ParallelTask, which is the guaranteed
pointee type of this runtime function argument (if pointee types
exist). The elimination of the callee bitcast is left for InstCombine.

Differential Revision: https://reviews.llvm.org/D120885
2022-03-15 09:52:46 +01:00
Matthias Springer
9597b16aa9 [mlir][bufferize][NFC] Split BufferizationState into AnalysisState/BufferizationState
Differential Revision: https://reviews.llvm.org/D121361
2022-03-15 17:35:47 +09:00
Jean Perier
83b0d0f964 [flang] fulfill -Msave/-fno-automatic in main programs too
`semantics::IsSaved()` was not applying -Msave/-fno-automatic for main programs.
This caused issues since lowering relies on it to allocate static
variables. This did not match nvfortran/gfortran behaviors where
-fno-automatic/-Msave control the static allocation of scalars in
main programs.

Some program may rely on main program scalars to be statically allocated in
bss (and therefore initialized to zero) with -Msave/-fno-automatic
flags.

Differential Revision: https://reviews.llvm.org/D121603
2022-03-15 09:33:07 +01:00
Matthias Springer
76b1601001 [mlir][bufferize] Fix config not passed to greedy rewriter
Also add a TODO to switch to a custom walk instead of the GreedyPatternRewriter, which should be more efficient. (The bufferization pattern is guaranteed to apply only a single time for every op, so a simple walk should suffice.)

We currently specify a top-to-bottom walk order. This is important because other walk orders could introduce additional casts and/or buffer copies. These canonicalize away again, but it is more efficient to never generate them in the first place.

Note: A few of these canonicalizations are not yet implemented.

Differential Revision: https://reviews.llvm.org/D121518
2022-03-15 17:32:38 +09:00
Siva Chandra Reddy
1ceb007939 [libc][Obvious] Fix typo in CMake file. 2022-03-15 08:32:05 +00:00
Jean Perier
a69cb78242 [flang] Hanlde COMPLEX 2/3/10 in runtime TypeCode(cat, kind)
Type codes for COMPLEX kinds 2, 3, and 10 were added in https://reviews.llvm.org/D117336
but handling for these kinds in TypeCode(cat, kind) has not been added
yet.

Differential Revision: https://reviews.llvm.org/D121587
2022-03-15 09:26:14 +01:00
Fangrui Song
252bc2b9f5 [MachineLICM] Simplify code and avoid adding nullptr values to ParentMap. NFC 2022-03-15 01:24:01 -07:00
Florian Hahn
ca1b2fc9fb
[LV] Remove LoopVectorBody from InnerLoopVectorizer. (NFCI)
Update places still referencing LoopVectorBody to use the vector loop to
get the vector loop header. This is needed to move vector loop
code-generation to VPlan completely, which in turn is needed to model
pre-header & exit blocks in VPlan as well.
2022-03-15 08:22:31 +00:00
River Riddle
bbfec2a1b0 [mlir] Remove the deprecated ODS Op verifier/parser/printer code blocks
These have been deprecated for ~1 month now and can be removed.

Differential Revision: https://reviews.llvm.org/D121090
2022-03-15 01:17:30 -07:00
Stanislav Gatev
092a530ca1 [clang][dataflow] Model the behavior of non-standard optional constructors
Model nullopt, inplace, value, and conversion constructors.

Reviewed-by: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D121602
2022-03-15 08:13:13 +00:00
Adrian Kuegel
fd8fe3bab6 [mlir][Bazel] Adjust build file to account for new td files. 2022-03-15 09:05:07 +01:00
Qiu Chaofan
300e1293de [PowerPC] Disable perfect shuffle by default
We are going to remove the old 'perfect shuffle' optimization since it
brings performance penalty in hot loop around vectors. For example, in
following loop sharing the same mask:

  %v.1 = shufflevector ... <0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27>
  %v.2 = shufflevector ... <0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27>

The generated instructions will be `vmrglw-vmrghw-vmrglw-vmrghw` instead
of `vperm-vperm`. In some large loop cases, this causes 20%+ performance
penalty.

The original attempt to resolve this is to pre-record masks of every
shufflevector operation in DAG, but that is somewhat complex and brings
unnecessary computation (to scan all nodes) in optimization. Here we
disable it by default. There're indeed some cases becoming worse after
this, which will be fixed in a more careful way in future patches.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D121082
2022-03-15 15:52:24 +08:00
River Riddle
23e3cbe24a [mlir] Refactor how parser/printers are specified for AttrDef/TypeDef
There is currently an awkwardly complex set of rules for how a
parser/printer is generated for AttrDef/TypeDef. It can change depending on if a
mnemonic was specified, if there are parameters, if using the assemblyFormat, if
individual parser/printer code blocks were specified, etc. This commit refactors
this to make what the attribute/type wants more explicit, and to better align
with how formats are specified for operations.

Firstly, the parser/printer code blocks are removed in favor of a
`hasCustomAssemblyFormat` bit field. This aligns with the operation format
specification (and is nice to remove code blocks from ODS).

This commit also adds a requirement to explicitly set `assemblyFormat` or
`hasCustomAssemblyFormat` when the mnemonic is set and the attr/type
has no parameters. This removes the weird implicit matrix of behavior,
and also encourages the author to make a conscious choice of either C++
or declarative format instead of implicitly opting them into the C++
format (we should be pushing towards declarative when possible).

Differential Revision: https://reviews.llvm.org/D121505
2022-03-15 00:42:31 -07:00
River Riddle
84d2549e82 [mlir] Rewrite and modernize the documentation for defining Attributes/Types
The current documentation is super old, crusty, and at times wrong. This commit
rewrites the documentation to focus on the TableGen declarative definition,
expounds on various components, and moves the doc out of Tutorials/ and into
a new top level `AttributesAndTypes.md` doc. As part of this, the AttrDef/TypeDef
documentation in OpDefinitions.md is removed.

Differential Revision: https://reviews.llvm.org/D120011
2022-03-15 00:19:52 -07:00
River Riddle
1d7120c69a [mlir] Split out AttrDef/TypeDef and pattern constructs from OpBase.td
OpBase.td has formed into a huge monolith of all ODS constructs. This
commits starts to rectify that by splitting out some constructs to their
own .td files.

Differential Revision: https://reviews.llvm.org/D118636
2022-03-15 00:18:03 -07:00
Mogball
4767e26775 [mlir][ods] Add support for custom directive in attr/type formats
This patch adds support for custom directives in attribute and type formats. Custom directives dispatch calls to user-defined parser and printer functions.

For example, the assembly format "custom<Foo>($foo, ref($bar))" expects a function with the signature

```
LogicalResult parseFoo(AsmParser &parser, FailureOr<FooT> &foo, BarT bar);
void printFoo(AsmPrinter &printer, FooT foo, BarT bar);
```

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D120944
2022-03-15 07:15:15 +00:00