platform/upstream/llvm.git
18 months ago[mlir][arith][NFC] Simplify narrowing patterns with a wrapper type
Jakub Kuderski [Mon, 1 May 2023 17:31:30 +0000 (13:31 -0400)]
[mlir][arith][NFC] Simplify narrowing patterns with a wrapper type

Add a new wraper type that represents either of `ExtSIOp` or `ExtUIOp`.
This is to simplify the code by using a single type, so that we do not
have to use templates or branching to handle both extension kinds.

Reviewed By: antiagainst

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

18 months agoFix ReleaseNotes.rst unresolved merge conflict
Alan Zhao [Mon, 1 May 2023 17:26:05 +0000 (10:26 -0700)]
Fix ReleaseNotes.rst unresolved merge conflict

18 months agoRevert "Host: generalise `GetXcodeSDKPath`"
Douglas Yung [Mon, 1 May 2023 17:22:53 +0000 (10:22 -0700)]
Revert "Host: generalise `GetXcodeSDKPath`"

This reverts commit ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9.

This breaks the build with GCC and affects at least 2 build bots:
https://lab.llvm.org/buildbot/#/builders/217/builds/20568
https://lab.llvm.org/buildbot/#/builders/243/builds/5576

18 months ago[LAA] Rework overflow checking in getPtrStride [nfc]
Philip Reames [Mon, 1 May 2023 17:16:32 +0000 (10:16 -0700)]
[LAA] Rework overflow checking in getPtrStride [nfc]

The previous code structure and comments were exceedingly confusing.  I have multiple times looked at this code and suspected a bug.  This time, I decided to take the time to reflow the code and comment out why it is correct.

The only suspect (to me) case left is that an underaligned access with a unit stride (in terms of the access type) might miss the undefined null pointer when wrapping.  This is unlikely to be an issue for C/C++ code with real page sizes, so I'm not bothering to fully convince myself whether that case is correct or not.

18 months ago[llvm-profdata] Deprecate Compact Binary Sample Profile Format
William Huang [Sat, 29 Apr 2023 00:30:25 +0000 (00:30 +0000)]
[llvm-profdata] Deprecate Compact Binary Sample Profile Format

Remove support for compact binary sample profile format

Reviewed By: davidxl, wenlei

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

18 months ago[clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization
Alan Zhao [Thu, 13 Apr 2023 18:04:59 +0000 (11:04 -0700)]
[clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

Before this patch, initialized class members would have the LifetimeKind
LK_MemInitializer, which does not allow for binding a temporary to a
reference. Binding to a temporary however is allowed in parenthesized
aggregate initialization, even if it leads to a dangling reference. To
fix this, we create a new EntityKind, EK_ParenAggInitMember, which has
LifetimeKind LK_FullExpression.

This patch does *not* attempt to diagnose dangling references as a
result of using this feature.

This patch also refactors TryOrBuildParenListInitialization(...) to
accomodate creating different InitializedEntity objects.

Fixes #61567

[0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html

Reviewed By: shafik

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

18 months ago[flang][hlfir] Fixed boxchar variables emboxing.
Slava Zakharin [Mon, 1 May 2023 16:53:45 +0000 (09:53 -0700)]
[flang][hlfir] Fixed boxchar variables emboxing.

We have to unbox the boxchar variables in order to get to
the raw address that can be used for emboxing.

Reviewed By: jeanPerier

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

18 months ago[flang][hlfir] Fixed lowering for optional dummy.
Slava Zakharin [Mon, 1 May 2023 16:06:02 +0000 (09:06 -0700)]
[flang][hlfir] Fixed lowering for optional dummy.

We have to keep it as a box, since taking box_addr of the optional
box may be invalid.

Reviewed By: jeanPerier

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

18 months ago[InstCombine] Combine const GEP chains
Yingwei Zheng [Mon, 1 May 2023 16:06:26 +0000 (00:06 +0800)]
[InstCombine] Combine const GEP chains

This patch reverts rGae739aefd7473517d3f08b5c8d08a66c7f469198 to address performance regressions reported by our [CI](https://github.com/dtcxzyw/llvm-ci/issues/137) after rG2ec1d0f427c7822540352c0c14d057e7bfe4f77b.

For example:
```
define ptr @const_gep_chain(ptr %p, i64 %a) {
    %p1 = getelementptr inbounds i8, ptr %p, i64 %a
    %p2 = getelementptr inbounds i8, ptr %p1, i64 1
    %p3 = getelementptr inbounds i8, ptr %p2, i64 2
    %p4 = getelementptr inbounds i8, ptr %p3, i64 3
    ret ptr %p4
}
```
The last three GEPs will not be folded since rG2ec1d0f427c7822540352c0c14d057e7bfe4f77b.

I think it is appropriate to remove this code because there is no compile-time regression reported in our benchmarks.

Reviewed By: nikic

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

18 months ago[clang] Fix default initializers being ignored when initializing templated aggregate...
Alan Zhao [Thu, 27 Apr 2023 22:31:51 +0000 (15:31 -0700)]
[clang] Fix default initializers being ignored when initializing templated aggregate types

Previously, when checking whether an in-class initializer exists when
performing parenthesized aggregate initialization, Clang checks that the
output of FieldDecl::getInClassInitializer() is non-null. This is
incorrect; if the field is part of a templated type, then
getInClassInitializer() will return nullptr if we haven't called
Sem::BuildCXXDefaultInitExpr(...) before, even if
FieldDecl::hasInClassInitializer() returns true. The end result is that
Clang incorrectly ignores the in class initializer and
value-initializes the field. The fix therefore is to instead call
FieldDecl::hasInClassInitializer(), which is what we do for braced init
lists [0].

Before this patch, Clang does correctly recognize the in-class field
initializer in certain cases. This is Sema::BuildCXXDefaultInitExpr(...)
populates the in class initializer of the corresponding FieldDecl
object. Therefore, if that method was previously called with the same
FieldDecl object, as can happen with a decltype(...) or a braced list
initialization, FieldDecl::getInClassInitializer() will return a
non-null expression, and the field becomes properly initialized.

Fixes 62266

[0]: https://github.com/llvm/llvm-project/blob/be5f35e24f4c15caf3c4aeccddc54c52560c28a0/clang/lib/Sema/SemaInit.cpp#L685

Reviewed By: shafik

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

18 months ago[gn build] Port 824391693cbb
LLVM GN Syncbot [Mon, 1 May 2023 16:04:47 +0000 (16:04 +0000)]
[gn build] Port 824391693cbb

18 months ago[libc++][PSTL] Implement std::find{,_if,_if_not}
Nikolas Klauser [Thu, 27 Apr 2023 23:28:22 +0000 (16:28 -0700)]
[libc++][PSTL] Implement std::find{,_if,_if_not}

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

18 months ago[LAA] Use early return [nfc]
Philip Reames [Mon, 1 May 2023 15:32:28 +0000 (08:32 -0700)]
[LAA] Use early return [nfc]

18 months ago[SystemZ][z/OS] Mark ecsymbols test as unsupported
Muiez Ahmed [Mon, 1 May 2023 15:25:14 +0000 (11:25 -0400)]
[SystemZ][z/OS] Mark ecsymbols test as unsupported

The llvm-lib tool is not yet supported on z/OS.

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

18 months agoSet EnableAIXExtendedAltivecABI in BackendUtils from LangOpts
Zarko Todorovski [Mon, 1 May 2023 14:30:29 +0000 (10:30 -0400)]
Set EnableAIXExtendedAltivecABI in BackendUtils from LangOpts

Fix a bug where after
github.com/llvm/llvm-project/commit/68dd51421f16f1e17cd453cb1730fcca99a6cfb7
refactor where we are not passing -mabi=vec-extabi to th backend.

18 months ago[RISCV] Rewrite isLegalElementTypeForRVV in terms of ValueTypes [nfc]
Philip Reames [Mon, 1 May 2023 14:32:55 +0000 (07:32 -0700)]
[RISCV] Rewrite isLegalElementTypeForRVV in terms of ValueTypes [nfc]

This was briefly mentioned as a possibility in review discussion on D149369.

One slightly surprising bit to call out - these interfaces can get invoked with non-vector typed arguments. LoopVectorizer likes to call the costing interfaces with scalar types when unrolling, but not vectorizing. I found that surprising, not sure if others do.

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

18 months ago[VPlan] Remove DeadInsts arg from VPInstructionsToVPRecipes (NFC)
Florian Hahn [Mon, 1 May 2023 14:03:15 +0000 (15:03 +0100)]
[VPlan] Remove DeadInsts arg from VPInstructionsToVPRecipes (NFC)

The argument isn't used. VPlan-based dead recipe removal can be used
instead.

18 months ago[clang] Temporarily enable debug output when uploading artifacts during CI jobs
Louis Dionne [Mon, 1 May 2023 13:48:13 +0000 (09:48 -0400)]
[clang] Temporarily enable debug output when uploading artifacts during CI jobs

This is an attempt to troubleshoot our excessive usage of network in
Clang jobs on Buildkite.

18 months agoEmit info message when use_device_address variable does not have a device counterpart.
Doru Bercea [Wed, 26 Apr 2023 14:41:10 +0000 (10:41 -0400)]
Emit info message when use_device_address variable does not have a device counterpart.

18 months agoFix the clang sphinx bot
Aaron Ballman [Mon, 1 May 2023 11:31:03 +0000 (07:31 -0400)]
Fix the clang sphinx bot

Addresses the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/43478

18 months ago[bazel] Fix layering check after 0610e2f
Christian Sigg [Mon, 1 May 2023 10:04:32 +0000 (12:04 +0200)]
[bazel] Fix layering check after 0610e2f

`BytecodeWriter.h` is now included in `IR.h`, and the corresponding dependency should be moved to `header_deps`. This change fixes Google's internal build, which seems to have a stricter layering check than bazel's, but it's still the right thing to do.

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

18 months ago[clangd][IncludeCleaner] Use a proper comparator for deduplicating findings
Kadir Cetinkaya [Mon, 1 May 2023 10:04:24 +0000 (12:04 +0200)]
[clangd][IncludeCleaner] Use a proper comparator for deduplicating findings

Previous one didn't have strict weak ordering guarantees.

18 months ago[compiler-rt][ASan] Fix description of __sanitizer_annotate_contiguous_container
Advenam Tacet [Mon, 1 May 2023 05:13:15 +0000 (22:13 -0700)]
[compiler-rt][ASan] Fix description of __sanitizer_annotate_contiguous_container

This revision updates the description of
`__sanitizer_annotate_contiguous_container` in includes. Possibilites of
the function were changed in D132522 and it supports:
  - unaligned beginning,
  - shared first/last granule with other objects.

Reviewed By: vitalybuka

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

18 months ago[mlir][bytecode] Return error instead of min version
Jacques Pienaar [Mon, 1 May 2023 05:11:02 +0000 (22:11 -0700)]
[mlir][bytecode] Return error instead of min version

Can't return a well-formed IR output while enabling version to be bumped
up during emission. Previously it would return min version but
potentially invalid IR which was confusing, instead make it return
error and abort immediately instead.

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

18 months ago[test][HWASAN] Auto-generate a few tests
Vitaly Buka [Mon, 1 May 2023 04:59:52 +0000 (21:59 -0700)]
[test][HWASAN] Auto-generate a few tests

18 months agoRevert "[NFC][HWASAN] Handle tags as Int8"
Vitaly Buka [Mon, 1 May 2023 03:59:05 +0000 (20:59 -0700)]
Revert "[NFC][HWASAN] Handle tags as Int8"

More tests need updates.

This reverts commit e876ba5db98830db427395ed9b3718d20bf519fb.

18 months ago[OpenMP] Only enable version script if supported
Shilei Tian [Mon, 1 May 2023 03:34:31 +0000 (23:34 -0400)]
[OpenMP] Only enable version script if supported

The linker flag `--version-script` may not be supported by all linkers, such as
macOS's linker. `libomp` is already capable of detecting whether the linker supports
it and append the linker flag accordingly. Since currently we assume `libomptarget`
only works on Linux, we don't do the check accordingly. This patch simply adds
the check before adding it to linker flag. This will be the first patch to make
OpenMP target offloading work on macOS. Note that CMake files in `plugins` are
not touched before they are going to be removed pretty soon anyway.

Reviewed By: jhuber6

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

18 months ago[NFC][HWASAN] Handle tags as Int8
Vitaly Buka [Sun, 30 Apr 2023 18:53:51 +0000 (11:53 -0700)]
[NFC][HWASAN] Handle tags as Int8

18 months ago[NFC][HWASAN] Rename local variable
Vitaly Buka [Mon, 1 May 2023 02:48:32 +0000 (19:48 -0700)]
[NFC][HWASAN] Rename local variable

18 months agoBasic documentation of -mrecip=... option
Tim Schmielau [Mon, 1 May 2023 01:54:20 +0000 (07:24 +0530)]
Basic documentation of -mrecip=... option

The documentation is still rather terse because it needs to fit
onto a single line of clang --help output.
But at least it lists what the user can specify and documents the
non-obvious syntax.

Reviewed By: craig.topper

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

18 months ago[NFC][HWASAN] Set constant type from another operand
Vitaly Buka [Mon, 1 May 2023 02:07:57 +0000 (19:07 -0700)]
[NFC][HWASAN] Set constant type from another operand

18 months ago[test][HWASAN] Remove update_test_checks note
Vitaly Buka [Sun, 30 Apr 2023 20:58:25 +0000 (13:58 -0700)]
[test][HWASAN] Remove update_test_checks note

This test is not autogenerated.

18 months ago[HWASAN] Untag before tagging alloca pointers
Vitaly Buka [Mon, 1 May 2023 01:10:40 +0000 (18:10 -0700)]
[HWASAN] Untag before tagging alloca pointers

This is folloup to b5595836, which missed the
Replacemen variable.

Before b5595836 the code assumed that alloca
ptrs are not tagged so tagging is implemented
as simple OR.

So this patch completes support of tagged SP
by passing untagged alloca pointers into
tagPointer.

18 months ago[LangRef] Fix broken tail call optimization link
Joshua Cao [Mon, 1 May 2023 01:17:48 +0000 (18:17 -0700)]
[LangRef] Fix broken tail call optimization link

18 months ago[MLIR][tensor] generate default builder for FromElementsOp
max [Sun, 30 Apr 2023 22:46:29 +0000 (17:46 -0500)]
[MLIR][tensor] generate default builder for FromElementsOp

Removed builder is the same as default builder, with the added benefit that python bindings will be generated for the default builder.

Reviewed By: ftynse

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

18 months agoDon't loop unswitch vector selects
Valentin Churavy [Sun, 30 Apr 2023 23:19:17 +0000 (19:19 -0400)]
Don't loop unswitch vector selects

Otherwise we could produce `br <2x i1>` which are of course not legal.

```
Branch condition is not 'i1' type!
  br <2 x i1> %cond.fr1, label %entry.split.us, label %entry.split
  %cond.fr1 = freeze <2 x i1> %cond
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/vchuravy/builds/llvm/bin/opt -passes=simple-loop-unswitch<nontrivial> -S
```

Fixes change introduced by https://reviews.llvm.org/D138526

Reviewed By: caojoshua

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

18 months ago[clang-format] Recognize Verilog type dimension in module header
sstwcw [Sun, 30 Apr 2023 22:26:41 +0000 (22:26 +0000)]
[clang-format] Recognize Verilog type dimension in module header

We had the function `verilogGroupDecl` for that.  However, the type
name would be incorrectly annotated in `isStartOfName` when it was not
a C++ keyword and followed another identifier.

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

18 months ago[clang-format] Correctly format goto labels followed by blocks
sstwcw [Sun, 30 Apr 2023 22:22:31 +0000 (22:22 +0000)]
[clang-format] Correctly format goto labels followed by blocks

There doesn't seem to be an issue on GitHub.  But previously, a space
would be inserted before the goto colon in the code below.

    switch (x) {
    case 0:
    goto_0: {
      action();
      break;
    }
    }

Previously, the colon following a goto label would be annotated as
`TT_InheritanceColon`.  A goto label followed by an opening brace
wasn't recognized.  It is easy to add another line to have
`spaceRequiredBefore` function recognize the case, but I believed it
is more proper to avoid doing the same thing in `UnwrappedLineParser`
and `TokenAnnotator`.  So now the label colons would be labeled in
`UnwrappedLineParser`, and `spaceRequiredBefore` would rely on that.

Previously we had the type `TT_GotoLabelColon` intended for both goto
labels and case labels.  But since handling of goto labels and case
labels differ somewhat, I split it into separate types for goto and
case labels.

This patch doesn't change the behavior for case labels.  I added the
lines annotating case labels because they would previously be
mistakenly annotated as `TT_InheritanceColon` just like goto labels.
And since I added the annotations, the checks for the `case` and
`default` keywords in `spaceRequiredBefore` are not necessary anymore.

Reviewed By: MyDeveloperDay

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

18 months agoRemove bug fix release note for a bug that was never released.
Richard Smith [Sun, 30 Apr 2023 22:13:22 +0000 (15:13 -0700)]
Remove bug fix release note for a bug that was never released.

In its place, add a description of a bug that the change introducing
the bug in question inadvertently fixed.

See BZ 62361 for more details.

18 months ago[gn build] Port 68ee014b15d3
LLVM GN Syncbot [Sun, 30 Apr 2023 20:27:26 +0000 (20:27 +0000)]
[gn build] Port 68ee014b15d3

18 months ago[libc++][PSTL] Implement std::for_each{, _n}
Nikolas Klauser [Thu, 19 Jan 2023 19:10:11 +0000 (20:10 +0100)]
[libc++][PSTL] Implement std::for_each{, _n}

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

18 months ago[LV] Clarify comment for selectVectorizationFactor (NFC).
Florian Hahn [Sun, 30 Apr 2023 20:12:15 +0000 (21:12 +0100)]
[LV] Clarify comment for selectVectorizationFactor (NFC).

The comment is stale, as UserVF is handled before selectVectorizationFactor
is called. Clarify the comment by remove the mention of UserVF.

Suggested as independent improvement in D143938.

18 months ago[LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC)
Florian Hahn [Sun, 30 Apr 2023 20:10:55 +0000 (21:10 +0100)]
[LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC)

LVP operates on the loop it stores in TheLoop. Use it instead of the
argument, to be in line with other member functions.

Suggested as independent improvement in D143938.

18 months ago[LV] Document selectEpilogueVectorizationFactor (NFC).
Florian Hahn [Sun, 30 Apr 2023 20:09:24 +0000 (21:09 +0100)]
[LV] Document selectEpilogueVectorizationFactor (NFC).

Add missing documentation for selectEpilogueVectorizationFactor.

Suggested as independent improvement in D143938.

18 months ago[clang-repl] Correctly disambiguate dtor declarations from statements.
Vassil Vassilev [Sun, 30 Apr 2023 19:43:38 +0000 (19:43 +0000)]
[clang-repl] Correctly disambiguate dtor declarations from statements.

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

18 months ago[clang-tidy] Ignore declarations in bugprone-exception-escape
Piotr Zegar [Sun, 30 Apr 2023 18:22:44 +0000 (18:22 +0000)]
[clang-tidy] Ignore declarations in bugprone-exception-escape

Warnings will now only be printed for function definitions, not declarations

Reviewed By: isuckatcs

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

18 months ago[LVP] Fix comment for hasPlanWithVF (NFC).
Florian Hahn [Sun, 30 Apr 2023 18:13:52 +0000 (19:13 +0100)]
[LVP] Fix comment for hasPlanWithVF (NFC).

The function checks if there's a plan with the specified VF. Update the
comment to match the implementation.

Pointed out as independent improvement in D143938.

18 months ago[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to...
Noah Goldstein [Sun, 30 Apr 2023 15:16:55 +0000 (10:16 -0500)]
[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to speculate

This just replaces the exact constant requirements with known-bits
which can prove better results.

Reviewed By: nikic

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

18 months ago[ValueTracking] Add tests for checking whether `div`/`rem` is safe to speculate; NFC
Noah Goldstein [Fri, 28 Apr 2023 04:21:29 +0000 (23:21 -0500)]
[ValueTracking] Add tests for checking whether `div`/`rem` is safe to speculate; NFC

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

18 months ago[ValueTracking] Slight refactor to avoid unnecessary work; NFC
Noah Goldstein [Sun, 30 Apr 2023 14:38:43 +0000 (09:38 -0500)]
[ValueTracking] Slight refactor to avoid unnecessary work; NFC

Two changes:
    1) Make some cases that conditionally returned unconditional.
    2) In cases of `Op0 != 0 || Op1 != 0` its better check `Op1` first
       as its more likely to be a constant due to canonicalization (so
       faster to get knownbits of).

Reviewed By: nikic

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

18 months ago[ValueTracking] Add additional cases for `isKnownNonZero(mul X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:38:38 +0000 (09:38 -0500)]
[ValueTracking] Add additional cases for `isKnownNonZero(mul X, Y)`

If either `X` or `Y` is odd and the other is non-zero, the result is
non-zero.

Alive2 Link:
    https://alive2.llvm.org/ce/z/9V7-es

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(smin/smax X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:22 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(smin/smax X, Y)`

For `smin` if either `X` or `Y` is negative, the result is non-zero.
For `smax` if either `X` or `Y` is strictly positive, the result is
non-zero.

For both if `X != 0` and `Y != 0` the result is non-zero.

Alive2 Link:
    https://alive2.llvm.org/ce/z/7yvbgN
    https://alive2.llvm.org/ce/z/zizbvq

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:18 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`

`(umin X, Y) != 0` -> `X != 0 && Y != 0`

Alive2 Link:
    https://alive2.llvm.org/ce/z/AQh67i

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(umax X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:14 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(umax X, Y)`

`(umax X, Y) != 0` -> `X != 0 || Y != 0`

Alive2 Link:
    https://alive2.llvm.org/ce/z/_Z9AUT

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:10 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`

The logic here is the same for `add` so reuse the existing helper
`isNonZeroAdd`

Alive2 Link:
    https://alive2.llvm.org/ce/z/mhKvC5

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(ssub.sat X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:03 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(ssub.sat X, Y)`

The logic here is the same for normal `(sub X, Y)`, so just reused
`isNonZeroSub`.

Alive2 Link:
    https://alive2.llvm.org/ce/z/9kSkMv

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(sshl.sat/ushl.sat X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:00 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(sshl.sat/ushl.sat X, Y)`

`(sshl/ushl X, Y) != 0` -> `X != 0`

Alive2 Links
    https://alive2.llvm.org/ce/z/4WLM2p
    https://alive2.llvm.org/ce/z/BHFng4

Reviewed By: nikic

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

18 months ago[ValueTracking] Add logic for `isKnownNonZero(ctlz/cttz X)`
Noah Goldstein [Sun, 30 Apr 2023 14:32:57 +0000 (09:32 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(ctlz/cttz X)`

for `cttz` if `X[0]` is non-zero, then the expression is non-zero.
for `ctlz` if `X[SignBit]` is non-zero, then the expression in
non-zero.

Alive2 Links:
    cttz (false): https://alive2.llvm.org/ce/z/ySQzbg
    cttz (true): https://alive2.llvm.org/ce/z/auiTCJ
    ctlz (false): https://alive2.llvm.org/ce/z/yk3sTJ
    ctlz (true): https://alive2.llvm.org/ce/z/-JuDty

Reviewed By: nikic

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

18 months ago[ValueTracking] Handle bitcasts between vec-int-ptr in `isKnownNonZero`
Noah Goldstein [Sun, 30 Apr 2023 14:32:54 +0000 (09:32 -0500)]
[ValueTracking] Handle bitcasts between vec-int-ptr in `isKnownNonZero`

We where missing these cases so something like:
`(bitcast to i32 (or v216 x, <2, 1>))`

would not be found to be non-zero.

Reviewed By: nikic

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

18 months ago[ValueTracking] Add more tests for `isKnownNonZero` cases; NFC
Noah Goldstein [Sun, 30 Apr 2023 14:32:51 +0000 (09:32 -0500)]
[ValueTracking] Add more tests for `isKnownNonZero` cases; NFC

Reviewed By: nikic

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

18 months ago[ValueTracking] Pull out logic for detecting if `(add X, Y)` is non-zero; NFC
Noah Goldstein [Sun, 30 Apr 2023 14:32:49 +0000 (09:32 -0500)]
[ValueTracking] Pull out logic for detecting if `(add X, Y)` is non-zero; NFC

Reviewed By: nikic

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

18 months ago[ValueTracking] Pull out logic for detecting if `(sub X, Y)` is non-zero; NFC
Noah Goldstein [Sun, 30 Apr 2023 14:32:44 +0000 (09:32 -0500)]
[ValueTracking] Pull out logic for detecting if `(sub X, Y)` is non-zero; NFC

Reviewed By: nikic

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

18 months ago[libc++] Fixes CI breakage.
Mark de Wever [Sun, 30 Apr 2023 12:38:05 +0000 (14:38 +0200)]
[libc++] Fixes CI breakage.

Reviewed By: #libc, Mordante

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

18 months ago[libc++][format] Removes vector dependency.
Mark de Wever [Thu, 20 Apr 2023 18:39:00 +0000 (20:39 +0200)]
[libc++][format] Removes vector dependency.

During the review of D140653 it was suggested to use vector in
__retarget_buffer instead of manually managing the memory. Due to the
requirements of the Standard it turns out format needs to include vector
leading to a cycle. Therefore switching back to manual memory
management.

This is a preparation to fix https://llvm.org/PR61314

Reviewed By: #libc, ldionne

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

18 months ago[LV] Sink collect* calls to LVP::plan() (NFC).
Florian Hahn [Sun, 30 Apr 2023 10:41:22 +0000 (11:41 +0100)]
[LV] Sink collect* calls to LVP::plan() (NFC).

Move calls of collect* helpers closer to where the cost-model is used.
Should help simplifying D142669 & D142670.

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

18 months agoRevert "[InstCombine] Generate better code for std::bit_floor from libstdc++"
Nuno Lopes [Sun, 30 Apr 2023 08:56:34 +0000 (09:56 +0100)]
Revert "[InstCombine] Generate better code for std::bit_floor from libstdc++"

This reverts commit d775fc390d3c78cc81872e276c4b1314f19af577.

The patch is wrong wrt undef and the author didn't fix it after 2 weeks.

18 months agoAdd an action for each iteration of the GreedyPatternRewriteDriver
Mehdi Amini [Thu, 23 Feb 2023 05:43:45 +0000 (22:43 -0700)]
Add an action for each iteration of the GreedyPatternRewriteDriver

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

18 months ago[LegalizeVectorOps][RISCV] Support condition code legalization for ISD::STRICT_FSETCC...
Craig Topper [Sun, 30 Apr 2023 05:55:41 +0000 (22:55 -0700)]
[LegalizeVectorOps][RISCV] Support condition code legalization for ISD::STRICT_FSETCC/FSETCCS during LegalizeVectorOps.

Switch RISC-V to legalize during LegalizeVectorOps instead of
LegalizeDAG. LegalizeDAG uses the OpVT for legalize action while
LegalizeVectorOps uses the result VT. We really should fix that.

18 months ago[RISCV] Prevent lowerVectorStrictFSetcc from creatin an ISD::AND with identical operands.
Craig Topper [Sun, 30 Apr 2023 04:42:45 +0000 (21:42 -0700)]
[RISCV] Prevent lowerVectorStrictFSetcc from creatin an ISD::AND with identical operands.

This AND immediately gets legalized to RISCVISD::VMAND_VL and we don't
yet have DAG combine to optimize that away. So this is a quick fix to
improve generated code.

18 months ago[SimpleLoopUnswitch] unswitch selects
Joshua Cao [Sat, 15 Apr 2023 23:04:58 +0000 (16:04 -0700)]
[SimpleLoopUnswitch] unswitch selects

The old LoopUnswitch pass unswitched selects, but the changes were never
ported to the new SimpleLoopUnswitch.

We unswitch by turning:

```
S = select %cond, %a, %b
```

into:

```
head:
br %cond, label %then, label %tail

then:
br label %tail

tail:
S = phi [ %a, %then ], [ %b, %head ]
```

Unswitch selects are always nontrivial, since the successors do not exit
the loop and the loop body always needs to be cloned.

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

Co-authored-by: Sergey Kachkov <sergey.kachkov@syntacore.com>
18 months ago[SimpleLoopUnswitch] Add unswitch select tests
Joshua Cao [Mon, 17 Apr 2023 00:25:05 +0000 (17:25 -0700)]
[SimpleLoopUnswitch] Add unswitch select tests

18 months ago[TableGen] Forward declare CodeGenRegister et al. (NFC)
Sergei Barannikov [Sun, 30 Apr 2023 04:00:20 +0000 (07:00 +0300)]
[TableGen] Forward declare CodeGenRegister et al. (NFC)

18 months ago[gn build] Port ebc05b93a11b
LLVM GN Syncbot [Sun, 30 Apr 2023 03:41:51 +0000 (03:41 +0000)]
[gn build] Port ebc05b93a11b

18 months ago[gn build] Port 8af259e8d90b
LLVM GN Syncbot [Sun, 30 Apr 2023 03:41:50 +0000 (03:41 +0000)]
[gn build] Port 8af259e8d90b

18 months ago[libc++][PSTL] Implement std::{any, all, none}_of
Nikolas Klauser [Sat, 14 Jan 2023 01:08:27 +0000 (02:08 +0100)]
[libc++][PSTL] Implement std::{any, all, none}_of

Reviewed By: ldionne, #libc

Spies: arichardson, libcxx-commits, miyuki

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

18 months ago[libc++][PSTL] Implement <execution> contents
Nikolas Klauser [Fri, 13 Jan 2023 21:48:23 +0000 (22:48 +0100)]
[libc++][PSTL] Implement <execution> contents

Reviewed By: ldionne, #libc

Spies: libcxx-commits, arichardson

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

18 months agoRevert "[NFC][LLD] Disambiguate RISCV and llvm::RISCV"
Vitaly Buka [Sun, 30 Apr 2023 02:20:41 +0000 (19:20 -0700)]
Revert "[NFC][LLD] Disambiguate RISCV and llvm::RISCV"

This reverts commit 176cc70abe8d85df9aae223e0b35ce65238c4333.

18 months ago[NFC][LLD] Disambiguate RISCV and llvm::RISCV
Vitaly Buka [Sun, 30 Apr 2023 02:06:18 +0000 (19:06 -0700)]
[NFC][LLD] Disambiguate RISCV and llvm::RISCV

Build is broken after ee9cbe35.

18 months agoRevert "[RISCV] Move RISCV::RVVBitsPerBlock from TargetParser to Support/RISCVISAInfo.h."
Craig Topper [Sun, 30 Apr 2023 01:05:56 +0000 (18:05 -0700)]
Revert "[RISCV] Move RISCV::RVVBitsPerBlock from TargetParser to Support/RISCVISAInfo.h."

This reverts commit ee9cbe3548cded885c6409d6dd8a616b515a06d3.

I've been told this cauess a namespace clash in lld.

18 months ago[RISCV] Use TokenFactor instead of MERGE_VALUES to combine chains.
Craig Topper [Sun, 30 Apr 2023 01:05:10 +0000 (18:05 -0700)]
[RISCV] Use TokenFactor instead of MERGE_VALUES to combine chains.

18 months ago[NFC][HWASAN] Use pointercast instead of bitcast
Vitaly Buka [Sun, 30 Apr 2023 00:40:33 +0000 (17:40 -0700)]
[NFC][HWASAN] Use pointercast instead of bitcast

18 months ago[NFC][HWASAN] Add cont to parameter
Vitaly Buka [Sun, 30 Apr 2023 00:22:45 +0000 (17:22 -0700)]
[NFC][HWASAN] Add cont to parameter

18 months ago[NFC][HWASAN] Fix comment
Vitaly Buka [Sun, 30 Apr 2023 00:22:12 +0000 (17:22 -0700)]
[NFC][HWASAN] Fix comment

18 months ago[NFC][HWASAN] Remove unused parameter
Vitaly Buka [Sun, 30 Apr 2023 00:14:39 +0000 (17:14 -0700)]
[NFC][HWASAN] Remove unused parameter

18 months ago[M68k] Add instruction selection support for zext with PCD addressing
Ian Douglas Scott [Sat, 29 Apr 2023 23:26:17 +0000 (16:26 -0700)]
[M68k] Add instruction selection support for zext with PCD addressing

Instruction selection was failing when trying to zero extend a value
loaded from a PC-relative address. This adds support for zero extension
using the "program counter indirect with displacement" addressing mode.
It also adds a test with code that was previously failing to compile.

This fixes a compile error in Rust's libcore.

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

18 months ago[X86] Update some stale comments. NFC
Craig Topper [Sat, 29 Apr 2023 22:38:31 +0000 (15:38 -0700)]
[X86] Update some stale comments. NFC

18 months ago[mlir][vector][NFC] Update `vector.flat_transpose` description
Jakub Kuderski [Sat, 29 Apr 2023 22:34:33 +0000 (18:34 -0400)]
[mlir][vector][NFC] Update `vector.flat_transpose` description

Change the example to match how this op is actually printed. Do not use
'smart quotes' in the description.

Reviewed By: jpienaar

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

18 months ago[TargetLowering] Stop passing an ISD::CondCode to isOperationLegalOrCustom.
Craig Topper [Sat, 29 Apr 2023 22:10:29 +0000 (15:10 -0700)]
[TargetLowering] Stop passing an ISD::CondCode to isOperationLegalOrCustom.

ISD::CondCode is a separate num space from opcodes. isOperationLegalOrCustom
should take an opcode.

Reviewed By: barannikov88

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

18 months ago[RISCV] Move RISCV::RVVBitsPerBlock from TargetParser to Support/RISCVISAInfo.h.
Craig Topper [Sat, 29 Apr 2023 22:04:52 +0000 (15:04 -0700)]
[RISCV] Move RISCV::RVVBitsPerBlock from TargetParser to Support/RISCVISAInfo.h.

RISCVTargetParser.h has a dependency on a tablegen generated file.

Using RISCVISAInfo.h instead avoids this dependency.

We just need this constant somewhere visible to the frontend and
backend and I'm trying to avoid adding a header just for it.

18 months ago[RISCV][Sema] Add a build dependency on RISCVTargetParserTableGen after D145088.
Craig Topper [Sat, 29 Apr 2023 20:33:02 +0000 (13:33 -0700)]
[RISCV][Sema] Add a build dependency on RISCVTargetParserTableGen after D145088.

Need to find a better home for RISCV::RVVBitsPerBlock to remove
this dependency. This just a quick fix to fix the build.

18 months ago[SCEV] Use object size for globals to sharpen ranges.
Florian Hahn [Sat, 29 Apr 2023 20:33:06 +0000 (21:33 +0100)]
[SCEV] Use object size for globals to sharpen ranges.

The highest address the object can start is ObjSize bytes before the
end (unsigned max value). If this value is not a multiple of the
alignment, the last possible start value is the next lowest multiple
of the alignment. Note: The computations cannot overflow,
because if they would there's no possible start address for the
object.

At the moment, this is limited to GlobalVariables, because I could not
find a API similar to getObjectSize to also get the alignment of the
object. With such an API, this can be generalized to general addresses.

Reviewed By: nikic

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

18 months agoGlobalOpt: Add some test coverage for addrspacecast treatment
Matt Arsenault [Sat, 29 Apr 2023 19:56:15 +0000 (15:56 -0400)]
GlobalOpt: Add some test coverage for addrspacecast treatment

18 months ago[ARM] Add predicated shift patterns
David Green [Sat, 29 Apr 2023 19:32:54 +0000 (20:32 +0100)]
[ARM] Add predicated shift patterns

This uses the patterns defined in MVE_TwoOpPattern to add predicated patterns
for vshls/u instructions.

Differnetial Revision: https://reviews.llvm.org/D149366

18 months agoAMDGPU: Don't need pointer bitcast in AMDGPULowerKernelArguments
Matt Arsenault [Sat, 29 Apr 2023 16:27:22 +0000 (12:27 -0400)]
AMDGPU: Don't need pointer bitcast in AMDGPULowerKernelArguments

18 months ago[SelectionDAG] Rename ADDCARRY/SUBCARRY to UADDO_CARRY/USUBO_CARRY (NFC)
Sergei Barannikov [Sat, 29 Apr 2023 18:07:04 +0000 (21:07 +0300)]
[SelectionDAG] Rename ADDCARRY/SUBCARRY to UADDO_CARRY/USUBO_CARRY (NFC)

This will make them consistent with other overflow-aware nodes.

Reviewed By: RKSimon

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

18 months ago[emacs] Highlight 'ptr' keyword as a type
Noah Goldstein [Sat, 29 Apr 2023 18:49:14 +0000 (13:49 -0500)]
[emacs] Highlight 'ptr' keyword as a type

Seems natural to highlight 'ptr' same as 'void', 'i1', etc...

Reviewed By: artagnon, nikic

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

18 months ago[InstCombine] Fold `(cmp eq/ne (umax X, Y),0)` -> `(cmp eq/ne (or X, Y),0)`
Noah Goldstein [Sat, 29 Apr 2023 16:26:33 +0000 (11:26 -0500)]
[InstCombine] Fold `(cmp eq/ne (umax X, Y),0)` -> `(cmp eq/ne (or X, Y),0)`

`or` is almost always preferable.

Reviewed By: nikic

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

18 months ago[InstCombine] Don't fold `uadd.sat` to `or` if it increase instruction count
Noah Goldstein [Fri, 28 Apr 2023 04:52:12 +0000 (23:52 -0500)]
[InstCombine] Don't fold `uadd.sat` to `or` if it increase instruction count

In the `(cmp eq/ne (uadd.sat X, Y),0)` case, we where missing a
`hasOneUse` check.

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

18 months ago[InstCombine] Add tests `(cmp eq/ne (umax/uadd.sat X, Y), 0)`; NFC
Noah Goldstein [Fri, 28 Apr 2023 04:09:05 +0000 (23:09 -0500)]
[InstCombine] Add tests `(cmp eq/ne (umax/uadd.sat X, Y), 0)`; NFC

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

18 months ago[TargetLowering] Don't use ISD::SELECT_CC in expandFP_TO_INT_SAT.
Craig Topper [Sat, 29 Apr 2023 17:06:22 +0000 (10:06 -0700)]
[TargetLowering] Don't use ISD::SELECT_CC in expandFP_TO_INT_SAT.

This function gets called for vectors and ISD::SELECT_CC was never
intended to support vectors. Some updates were made to support
it when this function started getting used for vectors.

Overall, using separate ISD::SETCC and ISD::SELECT looks like an
improvement even for scalar.

Reviewed By: RKSimon

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