537606 Commits

Author SHA1 Message Date
Simon Pilgrim
7cc200529f [X86] pr63108.ll - regenerate test checks 2025-05-15 10:13:49 +01:00
Ramkumar Ramachandra
c807395011
[LAA/SLP] Don't truncate APInt in getPointersDiff (#139941)
Change getPointersDiff to return an std::optional<int64_t>, and fill
this value with using APInt::trySExtValue. This simple change requires
changes to other functions in LAA, and major changes in SLPVectorizer
changing types from 32-bit to 64-bit.

Fixes #139202.
2025-05-15 10:08:05 +01:00
Vyacheslav Levytskyy
8bd35ca412
[SPIR-V] Fix LIT tests, improve ICmpInst's type inference (#139726)
1. There are failed LIT tests at the moment due to type inference
errors.
```
Failed Tests (3):
  LLVM :: CodeGen/SPIRV/pointers/ptr-eq-types.ll
  LLVM :: CodeGen/SPIRV/validate/sycl-hier-par-basic.ll
  LLVM :: CodeGen/SPIRV/validate/sycl-tangle-group-algorithms.ll
```
This PR improves type inference to fix the errors.

2. The following tests start passing:
```
Unexpectedly Passed Tests (2):
  LLVM :: CodeGen/SPIRV/pointers/resource-addrspacecast-2.ll
  LLVM :: CodeGen/SPIRV/pointers/resource-addrspacecast.ll
```
This PR removes XFAILS in those two test cases.
2025-05-15 10:46:54 +02:00
Juan Manuel Martinez Caamaño
9893f6bed3
[HIP] Fix return type in __clang_hip_cmath.h (#139697)
Before, some functions like `isgreater(float, double)` would return a
`double` instead of a `bool`.

Stumbled upon this bug while trying to adapt
[`External/CUDA/cmath.cu`](https://github.com/llvm/llvm-test-suite/blob/main/External/CUDA/cmath.cu)
to HIP.

```
/_llvm-test-suite/External/HIP/../CUDA/math_h.cu:617:20: error: static assertion failed due to requirement 'std::is_same<double, bool>::value':
617 |     static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
```
2025-05-15 10:38:04 +02:00
Nikolas Klauser
49bced456c
[libc++] Add basic constant folding for std::format (#107197)
```
-------------------------------------------------------------------
Benchmark                                        old            new
-------------------------------------------------------------------
BM_format_string<char>/1                     42.1 ns        7.67 ns
BM_format_string<char>/2                     22.3 ns        3.84 ns
BM_format_string<char>/4                     10.6 ns        1.92 ns
BM_format_string<char>/8                     5.31 ns       0.815 ns
BM_format_string<char>/16                    2.79 ns       0.480 ns
BM_format_string<char>/32                    1.63 ns       0.550 ns
BM_format_string<char>/64                   0.782 ns       0.276 ns
BM_format_string<char>/128                  0.397 ns       0.145 ns
BM_format_string<char>/256                  0.211 ns       0.066 ns
BM_format_string<char>/512                  0.154 ns       0.035 ns
BM_format_string<char>/1024                 0.146 ns       0.021 ns
BM_format_string<char>/2048                 0.125 ns       0.033 ns
BM_format_string<char>/4096                 0.097 ns       0.016 ns
BM_format_string<char>/8192                 0.077 ns       0.012 ns
BM_format_string<char>/16384                0.066 ns       0.010 ns
BM_format_string<char>/32768                0.062 ns       0.016 ns
BM_format_string<char>/65536                0.062 ns       0.016 ns
BM_format_string<char>/131072               0.443 ns       0.015 ns
BM_format_string<char>/262144               0.629 ns       0.017 ns
BM_format_string<char>/524288               0.715 ns       0.020 ns
BM_format_string<char>/1048576              0.757 ns       0.020 ns
BM_format_string<wchar_t>/1                  38.8 ns        34.0 ns
BM_format_string<wchar_t>/2                  19.4 ns        16.9 ns
BM_format_string<wchar_t>/4                  9.88 ns        8.45 ns
BM_format_string<wchar_t>/8                  6.30 ns        6.47 ns
BM_format_string<wchar_t>/16                 3.11 ns        3.21 ns
BM_format_string<wchar_t>/32                 1.60 ns        1.63 ns
BM_format_string<wchar_t>/64                0.899 ns       0.925 ns
BM_format_string<wchar_t>/128               0.676 ns       0.693 ns
BM_format_string<wchar_t>/256               0.658 ns       0.685 ns
BM_format_string<wchar_t>/512               0.556 ns       0.531 ns
BM_format_string<wchar_t>/1024              0.428 ns       0.402 ns
BM_format_string<wchar_t>/2048              0.328 ns       0.319 ns
BM_format_string<wchar_t>/4096              0.276 ns       0.274 ns
BM_format_string<wchar_t>/8192              0.252 ns       0.251 ns
BM_format_string<wchar_t>/16384             0.248 ns       0.246 ns
BM_format_string<wchar_t>/32768             0.229 ns       0.232 ns
BM_format_string<wchar_t>/65536             0.248 ns       0.246 ns
BM_format_string<wchar_t>/131072            0.250 ns       0.240 ns
BM_format_string<wchar_t>/262144             3.03 ns        3.03 ns
BM_format_string<wchar_t>/524288             3.14 ns        3.15 ns
BM_format_string<wchar_t>/1048576            3.60 ns        3.61 ns
BM_string_without_formatting<char>           32.2 ns       0.470 ns
BM_string_without_formatting<wchar_t>        38.8 ns        10.2 ns
```
2025-05-15 10:37:32 +02:00
Ricardo Jesus
e7e4d99c58
[AArch64] Use vecshiftL64 instead of vecshiftR64 to match scalar SLI imm. (#139904)
`SIMDScalarLShiftDTied` should be using `vecshiftL64` to match
the immediate argument rather than `vecshiftR64` as the latter
prevents the pattern from matching 0 (and allows 64 instead).

Fixes #139879.
2025-05-15 09:36:06 +01:00
Nikolas Klauser
fbdf38ed43
[libc++] run clang-tidy on src/ in the CI (#121198)
This adds a new test to run clang-tidy on the `src/` directory and
temporarily disables and clang-tidy checks that currently fail. They
will be enabled in follow-up patches.
2025-05-15 10:34:09 +02:00
Csanád Hajdú
947a52db7c
[AArch64] Prefer using DUP instead of INS where possible (#138549)
Replace all instances of `INS(IMPLICIT_DEF, 0, v, idx)` with
`DUP(v, idx)` in instruction selection.

`INS` (e.g. `mov v0.s[0], v1.s[1]`) has a value dependency on its output
register, which becomes a false dependency when we're inserting into an
`IMPLICIT_DEF` register. We can break this false dependency by using
`DUP` (e.g. `mov s0, v1.s[1]`) instead.
2025-05-15 10:31:09 +02:00
Pablo Antonio Martinez
ba5591e39d
[mlir][Transform] Reuse bbArgs in FuseIntoContainingOp (#135066)
When fusing two ops with the same output operand using
FuseIntoContainingOp, the current implementation makes both ops write
into a different value pointing to the same tensor. This, in the end,
will bufferize into two different buffers, which is sub-optimal. The
current patch solves this problem, adding support to reuse the tensor by
both consumer and producer.

More precisely, before FuseIntoContainingOp is applied, we may have two
ops that write into the same output tensor. However, the consumer would
be tiled, thus the op would write into the loop iter_args (i.e., it does
not write directly into the original tensor). When the producer is fused
into the loop, the output tensor of the producer remains the same, so
the consumer and producer writes into two different values (consumer
writes into the iter_args and producer into the original tensor).

The current patch clones the consumer into the loop and checks if the
consumer is writing to the same value pointed by the loop inits, in
which case, it makes the output point to such tensor.
2025-05-15 09:29:33 +01:00
George Chaltas
c4f7ab1d2e
[LV] Initialize IR block pointers in ILV. (NFC) (#139807)
Setting unitialized pointers to nullptr in InnerLoopVectorizer()
constructor. These were noticed during a review of the code. Seems like
a good idea to clean them up.
2025-05-15 09:18:45 +01:00
Alexander Romanov
eb5e66b82d
[RISCV] Change type of Zicbop prefetch operand to GPRMem (#139888)
Prior to this commit PREFETCH_* instructions considered their operand
register to be a simple GPR which is not entirely correct as it is a
base address for possible prefetching operation (According to cmobase
v1.0.1)
2025-05-15 11:18:22 +03:00
Kerry McLaughlin
0bc3993716
[SelectionDAG] Add an ISD node for for get.active.lane.mask (#139084)
For now expansion still happens in SelectionDAGBuilder when
GET_ACTIVE_LANE_MASK is not legal on the target.

This patch also includes changes in AArch64ISelLowering to replace
handling of the get.active.lane.mask intrinsic to use the ISD node.
Tablegen patterns are added which match to whilelo for scalable types.

A follow up change will add support for more types to be lowered to
GET_ACTIVE_LANE_MASK by allowing splitting of the node.
2025-05-15 09:14:46 +01:00
YunQiang Su
780054d3ff
CodeGen: Add ISD::AssertNoFPClass (#138839)
It is used to mark a value that we are sure that it is not some fcType.
The examples include:

  * An arguments of a function is marked with nofpclass
  * Output value of an intrinsic can be sure to not be some type

So that the following operation can make some assumptions.
2025-05-15 16:05:15 +08:00
Adam Siemieniuk
c15539cdc4
[mlir][x86vector] Improve intrinsic operands creation (#138666)
Refactors intrinsic op interface to delegate initial operands mapping to
the dialect converter and allow intrinsic operands getters to only
perform last mile post-processing.
2025-05-15 09:58:43 +02:00
Pierre van Houtryve
aa9f8596b0
[AMDGPU] Add flag to prevent reruns of LowerModuleLDS (#129520)
FullLTO has to run this early before module splitting occurs otherwise
module splitting won't work as expected. There was a targeted fix for
fortran on another branch that disables the LTO run but that'd break
full LTO module splitting entirely.

Test changes are due to metadata indexes shifting.

See #122891
2025-05-15 09:54:21 +02:00
Juan Manuel Martinez Caamaño
291fa641ec
Pre-Commit tests: [HIP] Fix return type in __clang_hip_cmath.h (#139891)
Tests related to https://github.com/llvm/llvm-project/pull/139697
2025-05-15 09:51:33 +02:00
Pavel Labath
85c3c98630
[lldb] Fix offset computation in RegisterContextUnwind (#137155)
AddressFunctionScope was always returning the first address range of the
function (assuming it was the only one). This doesn't work for
RegisterContextUnwind (it's only caller), when the function doesn't
start at the lowest address because it throws off the 'how many bytes
"into" a function I am' computation. This patch replaces the result with
a call to (recently introduced)
SymbolContext::GetFunctionOrSymbolAddress.
2025-05-15 09:39:11 +02:00
Benjamin Maxwell
647db1b02d
Reland "[AArch64][SME] Split SMECallAttrs out of SMEAttrs" (#138671)
SMECallAttrs is a new helper class that holds all the SMEAttrs for a
call. The interfaces to query actions needed for the call (e.g. change
streaming mode) have been moved to the SMECallAttrs class.

The main motivation for this change is to make the split between the
caller, callee, and callsite attributes more apparent.

Before this change, we would always merge callsite and callee
attributes. The main reason to do this was to handle indirect calls,
however, we also occasionally used callsite attributes on direct calls
in tests (mainly to avoid creating multiple function declarations). With
this patch, we now explicitly handle indirect calls and disallow
incompatible attributes on direct calls (so this patch is not entirely
an NFC).

Same as #137239, but with a change to avoid inferring SME attributes for
function definitions. This allows stubbing the SME ABI routines in C/C++
(and matches the old behaviour).
2025-05-15 08:37:08 +01:00
Matt Arsenault
ab119add35
LangRef: Fix minimumnum/maximumnum nan handling phrasing (#139228)
Make this consistent with other operations with respect to
signaling nan quieting. This was specifying that quieting is
required, which is true for IEEE. Make this consistent with other
IR operations, and signaling nan quieting is possible but optional
in the case where there are two nan inputs.

This permits directly selecting the intrinsic to the hardware
instruction in the default floating-point environment for shaders.
2025-05-15 09:07:09 +02:00
Nikolas Klauser
53f11dd4d6
[libc++] Avoid type-punning between __value_type and pair (#134819)
Before this patch, we were dereferencing pointers to objects which were
never constructed. Now we always assume that nodes store `pair<const
KeyT, ValueT>` for maps instead, as they actually do. This patch also
allows for significant follow-up simplifications, since
`__node_value_type` and `__container_value_type` are the same type now.
2025-05-15 09:01:56 +02:00
Kazu Hirata
70ef89b913
[AMDGPU] Use std::optional::value_or (NFC) (#140006) 2025-05-14 23:50:13 -07:00
Kazu Hirata
690a30f3fd
[llvm] Construct SmallVector with ArrayRef (NFC) (#139992) 2025-05-14 22:30:38 -07:00
Madhur Amilkanthwar
40778822f7
[GVN][NFC] Add MSSA checks in tests 2/N (#137814)
The previous patch in this series is #130261
2025-05-15 10:29:41 +05:30
Fangrui Song
369c409348
Support,lld: Rename misnamed F_no_mmap to F_mmap
`F_no_mmap` introduced by https://reviews.llvm.org/D69294 is misnamed.
It oughts to be `F_mmap`

When the output is a regular file or do not exist,
`--no-mmap-output-file` is the default. Relands #134787 by fixing the
lld option default. Note: changing the default to --map-output-file
would likely fail on llvm-clang-x86_64-sie-win
(https://lab.llvm.org/buildbot/#/builders/46/builds/14847)

Pull Request: https://github.com/llvm/llvm-project/pull/139836
2025-05-14 21:00:49 -07:00
Iris Shi
99e8d22d69
[RISCV][Scheduler] Add scheduler definitions for the Q extension (#139495) 2025-05-15 10:58:13 +08:00
Iris Shi
25e91ed202
[RISCV][MC] Add Q support for Zfa (#139508)
https://github.com/riscv/riscv-isa-manual/blob/main/src/zfa.adoc
2025-05-15 10:54:16 +08:00
Iris Shi
1e503d08e1
[RISCV][MC] Add support for Q extension (#139369)
Closes #130217.

https://github.com/riscv/riscv-isa-manual/blob/main/src/q-st-ext.adoc
2025-05-15 10:51:06 +08:00
Matt
4630d464c5
[clang] Fix a segfault when M is a nullptr (#130712)
If `MM->getOwningModule` returns nullptr, then `isVisible` is called
with nullptr, which then calls `getImportLoc(nullptr)`


077e0c134a/clang/lib/Lex/PPMacroExpansion.cpp (L208)
2025-05-15 10:50:45 +08:00
Jim Lin
ee78697519
[RISCV] Support LLVM IR intrinsics for XAndesVPackFPH (#139860)
This patch adds LLVM IR intrinsic support for XAndesVPackFPH.

The document for the intrinsics can be found at:
https://github.com/andestech/andes-vector-intrinsic-doc/blob/ast-v5_4_0-release-v5/auto-generated/andes-v5/intrinsic_funcs.adoc#andes-vector-packed-fp16-extensionxandesvpackfph
and with policy variants
https://github.com/andestech/andes-vector-intrinsic-doc/blob/ast-v5_4_0-release-v5/auto-generated/andes-v5/policy_funcs/intrinsic_funcs.adoc#andes-vector-packed-fp16-extensionxandesvpackfph

The clang part will be added in a later patch.

Co-authored-by: Tony Chuan-Yue Yuan <yuan593@andestech.com>
2025-05-15 10:21:27 +08:00
Jim Lin
2a8960e48b
[RISCV] Add Andes XAndesVDot (Andes Vector Dot Product) extension. (#139849)
The spec can be found at:

https://github.com/andestech/andes-v5-isa/releases/tag/ast-v5_4_0-release.

This patch only supports assembler.

Intrinsics support will be added in a later patch.
2025-05-15 10:14:58 +08:00
Helena Kotas
520773b47e
[HLSL] Add resource constructor with implicit binding for global resources (#138976)
Adds constructor for resources with implicit binding and applies it to
all resources without binding at the global scope.
Adds Clang builtin function
`__builtin_hlsl_resource_handlefromimplicitbinding` that gets translated
to `llvm.dx|spv.resource.handlefromimplicitbinding` intrinsic calls.
Specific bindings are assigned in DXILResourceImplicitBinding pass.

Design proposals:

https://github.com/llvm/wg-hlsl/blob/main/proposals/0024-implicit-resource-binding.md

https://github.com/llvm/wg-hlsl/blob/main/proposals/0025-resource-constructors.md

One change from the proposals is that the `orderId` parameter is added
onto the constructor. Originally it was supposed to be generated in
codegen when the `llvm.dx|spv.resource.handlefromimplicitbinding` call
is emitted, but that is not possible because the call is inside a
constructor, and the constructor body is generated once per resource
type and not resource instance. So the only way to inject instance-based
data like `orderId` into the
`llvm.dx|spv.resource.handlefromimplicitbinding` call is that it must
come in via the constructor argument.

Closes #136784
2025-05-14 18:41:17 -07:00
Longsheng Mou
34be80aa6e
[mlir-runner] Check entry function does not expect arguments (#136825)
This PR fixes a crash if entry function has inputs. Fixes #136143.
2025-05-15 09:19:39 +08:00
Qinkun Bao
18b885f66b
Revert "[clang][modules] Timestamp-less validation API" (#139987)
Reverts llvm/llvm-project#138983
2025-05-14 21:02:57 -04:00
Krzysztof Parzyszek
41fcd7e78b
[ADT] Add operator! to BitmaskEnum (#139958)
Add a logical (boolean) "not" operator.
2025-05-14 19:36:42 -05:00
LLVM GN Syncbot
8b53ada242 [gn build] Port 5b9246517f8f 2025-05-14 23:26:39 +00:00
LLVM GN Syncbot
699a2f188d [gn build] Port 14836597f5d8 2025-05-14 23:26:38 +00:00
LLVM GN Syncbot
87e6f1d7eb [gn build] Port 0ab67ec19167 2025-05-14 23:26:37 +00:00
Nico Weber
3a9992d248 [gn] port ec406e86745af 2025-05-14 19:25:02 -04:00
Nico Weber
d0a6b2f4c0 [gn] port 3bdfa6f3e8eb 2025-05-14 19:20:00 -04:00
Nishant Patel
1778d3b824
[mlir] [vector] Add linearization pattern for vector.create_mask (#138214)
This PR is a breakdown [3 / 4] of the PR #136193 
The PR adds linearization patterns for vector.create_mask
2025-05-14 15:53:58 -07:00
Ethan Luis McDonough
1043810769
[PGO][Offload] Update PGO GPU tests (#132262) 2025-05-14 17:17:52 -05:00
Alex MacLean
847561e48f
[NVPTX] Further refactor intrinsic definitions to remove redundancy (NFC) (#139924)
Note: the diff indicates this change has no impact on the intrinsic code
generated by table-gen.
2025-05-14 15:04:16 -07:00
James Newling
21f1a616d6
[mlir][vector] Additional transpose folding (#138347)
Fold transpose with unit-dimensions. Seen in the wild:
```
 %0 = vector.transpose %arg, [0, 2, 1, 3] : vector<6x1x1x4xi8> to vector<6x1x1x4xi8>
```

This transpose can be folded because (1) it preserves the shape and (2)
the shuffled dims are unit extent.

Also addresses comment about static vs anonymous namespace:
https://github.com/llvm/llvm-project/pull/135841#discussion_r2071869067

---------

Signed-off-by: James Newling <james.newling@gmail.com>
2025-05-14 14:56:35 -07:00
Thurston Dang
0dd2c9f7a3 Fix-forward build error from #132489
Replace deprecated use of getDeclaration that was added in #132489

llvm/lib/IR/AutoUpgrade.cpp:1480:26: error: 'getDeclaration' is deprecated: Use getOrInsertDeclaration instead [-Werror,-Wdeprecated-declarations]
 1480 |       NewFn = Intrinsic::getDeclaration(
      |                          ^~~~~~~~~~~~~~
      |                          getOrInsertDeclaration
2025-05-14 21:44:13 +00:00
Jan Svoboda
960afcc90e
[clang][modules] Timestamp-less validation API (#138983)
Timestamps are an implementation detail of the cross-process module
cache implementation. This PR hides it from the `ModuleCache` API, which
simplifies the in-process implementation.
2025-05-14 14:31:23 -07:00
Andrew Rogers
a608b49142
[llvm] clang-format llvm/CodeGen/Passes.h (#139951)
Reformat a few header files under llvm/include/llvm/CodeGen/Passes.h
with clang-format in preparation for a codemod.

This is just a formatting change; no functionality is impacted.
2025-05-14 14:17:56 -07:00
Sergei Barannikov
e8b2c3176a
[M68k] TableGen-erate SDNode descriptions (#139449)
This consolidates node definitions into one place and enables automatic
node verification.

Part of #119709.
2025-05-15 00:12:27 +03:00
Aiden Grossman
d46458c11b [llvm-exegesis] Disable test
This patch disables the skip unsupported instructions test on AArch64. On
machines that have hardware support for pointer authentication the test will
try and disable certain features, but currently fails depending upon the
configuration.
2025-05-14 21:02:14 +00:00
Jessica Clarke
864f0ff4ef
[clang][IR] Overload @llvm.thread.pointer to support non-AS0 targets (#132489)
Thread-local globals live, by default, in the default globals address
space, which may not be 0, so we need to overload @llvm.thread.pointer
to support other address spaces, and use the default globals address
space in Clang.
2025-05-14 21:51:56 +01:00
Min-Yih Hsu
0ab67ec191
[LV][EVL] Introduce the EVLIndVarSimplify Pass for EVL-vectorized loops (#131005)
When we enable EVL-based loop vectorization w/ predicated tail-folding,
each vectorized loop has effectively two induction variables: one
calculates the step using (VF x vscale) and the other one increases the
IV by values returned from experiment.get.vector.length. The former,
also known as canonical IV, is more favorable for analyses as it's
"countable" in the sense of SCEV; the latter (EVL-based IV), however, is
more favorable to codegen, at least for those that support scalable
vectors like AArch64 SVE and RISC-V.

The idea is that we use canonical IV all the way until the end of all
vectorizers, where we replace it with EVL-based IV using EVLIVSimplify
introduced here. Such that we can have the best from both worlds.

This Pass is enabled by default in RISC-V. However, since we haven't
really vectorize loops with predicate tail-folding by default, this Pass
is no-op at this moment.
2025-05-14 13:49:50 -07:00