573996 Commits

Author SHA1 Message Date
Deric C.
bcfe1e94d3
[HLSL] Allow 1x1 matrices to be splatted like scalars (#188119)
Fixes #186859 by allowing 1x1 matrices to be splatted like the scalar
and vec1 cases.

Assisted-by: GitHub Copilot (powered by Claude Opus 4.6)
2026-03-23 14:49:53 -07:00
lntue
599d74fdc3
[libc][math] Reduce memory usage for single precision inverse hyperbolic functions for LIBC_MATH_HAS_SMALL_TABLES option. (#188110) 2026-03-23 21:41:21 +00:00
vangthao95
2bee958599
[AMDGPU][NFC] Update test to use update_llc_test_checks (#188102)
Also add globalisel run lines.

Precommit test for https://github.com/llvm/llvm-project/pull/187834.
2026-03-23 14:17:23 -07:00
Arthur Eubanks
53e3ed82f6
[gn build] Port commits (#188129)
f7d5e593d38a
b2edc0a3f8a5
3e4efe3ed4a2
2026-03-23 14:15:46 -07:00
Joseph Huber
fe03749f08
[Clang] Do not emit multi-gpu warning if they are all the same (#185490)
Summary:
This warning exists because if you do `-mcpu=native` in some contexts it
may not be obvious which GPU you get. But if they are all the same then
it really don't make a difference since we just pass the first one to
`-mcpu` anyway. Relax this so it doesn't annoyingly warn on machines
with more than one of the same GPU.

---------

Co-authored-by: Jacob Lambert <jacob.lambert@amd.com>
2026-03-23 16:09:34 -05:00
Arthur Eubanks
a235d96e48
[test][ASan] Precommit test for #187794 (#188112) 2026-03-23 21:02:17 +00:00
Zhen Wang
c0634cbb07
[flang][cuda] Add CUFRegisterManagedVariable runtime entry for __cudaRegisterManagedVar (#188124)
Add CUFRegisterManagedVariable runtime wrapper in flang-rt that calls
__cudaRegisterManagedVar.
This is preparation for supporting non-allocatable managed variables.
No functional change -- nothing calls this yet.
2026-03-23 14:01:24 -07:00
Florian Hahn
2f1e0d14f4
[LV] Add additional epilogue vector tests.
Add additional epilogue vectorization tests for
 * https://github.com/llvm/llvm-project/issues/187323
 * https://github.com/llvm/llvm-project/issues/185345
2026-03-23 20:44:00 +00:00
vangthao95
22977fd99e
[AMDGPU][NFC] Update permute tests to use auto-generated checks (#188107)
Also add global-isel run line.
2026-03-23 13:29:38 -07:00
Alireza Torabian
3124cb3fe7
[DA] Bug fix regarding the SameSD levels (#188098)
SCEV isKnownPredicate may crash if the expressions are involved with
different loops. To verify if two loops have the same iteration space,
we do not need to use the SCEV apis, and it can be done by the equality
check.

Moreover, no pass (not even loop fusion) requires to check SameSD levels
for more than one level. In this patch, we limit the analysis of SameSD
levels to only one level after the common levels.
2026-03-23 20:23:11 +00:00
Afonso Rafael (Gafanhoto)
9096c9cda3
[LoopFusion] Remove the InvalidDependencies duplicates (#187744)
If the function dependencesAllowFusion returns false, in fuseCandidates
the reportLoopFusion function is used to increment InvalidDependencies
and to emit a OptimizationRemarkMissed. If both dependencesAllowFusion
and reportLoopFusion increment InvalidDependencies, statistics will
appear duplicated
2026-03-23 16:13:46 -04:00
Susan Tan (ス-ザン タン)
205187c5cf
[openacc][flang] full support to handle allocatable/pointer runtime declare-action calls in ACCDeclareActionConversion (#188055)
Supported before: `fir.store`, `fir.box_addr`, and `fir.call` only for
PointerAllocate/PointerDeallocate.
Added now: fir.call support for PointerAllocateSource,
PointerDeallocatePolymorphic, AllocatableAllocate,
AllocatableAllocateSource, AllocatableDeallocate,
AllocatableDeallocatePolymorphic (found in
flang/include/flang/Runtime/allocatable.h).
2026-03-23 19:50:40 +00:00
Jonas Devlieghere
f7d5e593d3
[lldb] Check for arm64e debugserver in skipUnlessArm64eSupported (#188082)
Explicitly check whether we are building debugserver for arm64e. To
debug an arm64e binary, debugserver itself needs to be an arm64e
process.

This PR eliminates the possibility of configuring LLDB with Right now,
it's possible to configure CMake with
`LLDB_ENABLE_ARM64E_DEBUGSERVER=Off` and the decorator wouldn't account
for that.
2026-03-23 14:45:05 -05:00
Owen Anderson
9acfa56d8f
[Coro] Preserve program address spaces correctly in CoroSplit. (#188002) 2026-03-23 20:40:50 +01:00
Aiden Grossman
e38e87dbb0 [LoongArch] Fix -Wunused-variable in c4b01ec20d3e845d348b0b005102b1301a8550ca
This variable was only used in assertions which was causing warnings in
release+noasserts builds.
2026-03-23 19:24:00 +00:00
vporpo
0c1013bfd4
[IR][NFC] Rename UncondBrInst 'IfTrue' argument to 'Target' (#187631)
Follow-up on @slackito's suggestion about the naming of the variable and
discussion with @aengelke in #187196
2026-03-23 12:17:19 -07:00
kwyatt-ext
0ae0ee0361
[flang] Adding a new extension that was noticed to be intentionally in the code. (#182891)
The flang compiler intentionally issues a warning on duplicate
prefix-specs for procedures. This is not consistent with the standard
which says "shall contain at most one of each". Other tested compilers
correctly issue an error.

It is safe to leave this as a warning. It can be turned into an error
condition by using the "-Werror" flag.

However, it should be noted in the Extensions document, similar to the
mention of the SAVE attribute.
2026-03-23 14:05:06 -05:00
Amy Kwan
b75222caf3 [clang][Driver][CMake] Link pthread when available to fix shared-lib link errors. 2026-03-23 19:09:31 +00:00
Andy Kaylor
729480c4ae
[CIR] Generalize cxx alloc new size handling (#187790)
The non-constant size handling in `emitCXXNewAllocSize` was making the
incorrect assumption that the default behavior of the size value being
explicitly cast to size_t would be the only behavior we'd see. This is
actually only true with C++14 and later. To properly handle earlier
standards, we need the more robust checking that classic codegen does in
the equivalent function. This change adds that handling.

Assisted-by: Cursor / claude-4.6-opus-high
2026-03-23 11:47:16 -07:00
Austin Kerbow
89503bda38
[AMDGPU] Add structural stall heuristic to scheduling strategies (#169617)
Implements a structural stall heuristic that considers both resource
hazards and latency constraints when selecting instructions. In coexec,
this changes the pending queue from a binary “not ready to issue”
distinction into part of a unified candidate comparison. Pending
instructions still identify structural stalls in the current cycle, but
they are now evaluated directly against available instructions by stall
cost, making the heuristics both more intuitive and more expressive.

- Add getStructuralStallCycles() to GCNSchedStrategy that computes the
number of cycles an instruction must wait due to:
  - Resource conflicts on unbuffered resources (from the SchedModel)
  - Sequence-dependent hazards (from GCNHazardRecognizer)

- Add getHazardWaitStates() to GCNHazardRecognizer that returns the
number
of wait states until all hazards for an instruction are resolved,
providing cycle-accurate hazard information for scheduling heuristics.
2026-03-23 11:33:43 -07:00
Henrich Lauko
412aaeb739
[CIR] Add Involution trait to BitReverseOp and ByteSwapOp (#187862)
bitreverse(bitreverse(x)) == x and byte_swap(byte_swap(x)) == x are
mathematical involutions.

This adds MLIR Involution trait to CIR opetation, it encodes this
property and automatically folds away the outer application when an op's
input is produced by the same op type.
2026-03-23 19:33:41 +01:00
idubinov
e672e88a96
[SPIRV] Fix OpBuildNDRange (#186153)
- Fix buildNDRange according to OpenCL and SPIRV specs.
- Fix tablegen SPIRV builtins for ndrange_* functions: despite of OpenCL
spec, the real call has additional first argument - structure return,
changed min and max num arguments accordingly.
 - Update test, add checks, combined with BuildNDRange_2
2026-03-23 19:11:04 +01:00
vangthao95
d2e70414b6
AMDGPU/GlobalISel: RegBankLegalize rules for live_mask (#187833) 2026-03-23 11:01:46 -07:00
google-llvm-bazel-bot
dc4073fbe7
[Bazel] Fixes 239ca11 (#188083)
This fixes 239ca11a55b40ce12b21bc47e45cb4065d1cc3d4.
2026-03-23 13:58:07 -04:00
Pranav Bhandarkar
87bab31c27
[Flang] - Add optional inlining of allocatable assignments with hlfir.expr RHS (#186880)
Add support for inlining hlfir.assign operations where the LHS is an
allocatable and the RHS is an `hlfir.expr` (e.g., from
`hlfir.elemental`). Since `hlfir.expr` values cannot alias with memory
locations, these assignments can be safely inlined without alias
analysis.

The optimization is controlled by the
-inline-hlfir-allocatable-expr-assign flag:
fir-opt -inline-hlfir-allocatable-expr-assign --inline-hlfir-assign
file.fir
  flang -mmlir -inline-hlfir-allocatable-expr-assign file.f90

The generated code uses `fir:🏭:genReallocIfNeeded` to properly
handle Fortran allocatable assignment semantics (F2018 10.2.1.3):
- If not allocated: allocate with RHS shape
- If allocated with same shape: reuse existing allocation
- If allocated with different shape: reallocate

This is motivated by the increased link time that I am seeing when
`__FortranAAssign` is called from the user code. The details of the
problem are documented in
https://github.com/llvm/llvm-project/issues/187720
2026-03-23 12:49:49 -05:00
Mark Danial
b32d078782
[AIX] XFAIL mlir builtin test on big endian AIX [NFC] (#187365)
Similar to https://github.com/llvm/llvm-project/pull/186305
2026-03-23 13:48:48 -04:00
Leandro Lupori
291923ba16
[flang][OpenMP] Privatize indirectly referenced symbols (#187097)
Symbols that may be referenced indirectly by lastprivate or linear
DSAs in nested constructs must not have their privatization skipped
in the enclosing context. This avoids updates to the wrong symbols.

This is needed to unblock PRs that fix #170784.

Fixes #179345
2026-03-23 14:43:51 -03:00
khaki3
4219fb8a21
[flang] Fix FIRToMemRef index computation for array_coor with shape_shift and slice (#186523)
When fir.array_coor carries an explicit shape_shift (non-default lower
bounds) and an explicit slice, the indices are Fortran indices rather
than 1-based section indices. The FIRToMemRef pass was unconditionally
subtracting 1 from sliced indices, which is only correct for 1-based
section indices (the embox-with-embedded-slice case).

For shape_shift + explicit slice, the correct adjustment is to subtract
the slice lower bound instead of 1. This produces proper 0-based memref
indices.

This pattern arises after the FIR inliner canonicalizes
fir.embox(shape_shift, slice) + fir.array_coor(box) into a single
fir.array_coor with explicit shape_shift and slice operands, where the
indices become Fortran indices.

Without this fix, arrays with non-default lower bounds (e.g., A(0:N) or
A(-1:N)) produce negative memref indices, writing before the array
allocation and causing a segfault.
2026-03-23 10:35:27 -07:00
Andrei Elovikov
a9ae2fd79e
[NFC][LV] Fix what seems to be a typo in the test (#187769)
The test was added in
4e9894498e.

Alternative fixes would be:
* Remove unused GEP, although not clear why we'd want to overwrite
stored `i64` with `ptr` store.
* Keep this patch, but perform both GEPs with `i64` element type to
reduce the diff. It's not clear if the scalarization caused by that type
mismatch is intentional/relevant for the original change.
2026-03-23 17:28:32 +00:00
Simon Pilgrim
4cef1c1341
[X86] canonicalizeShuffleWithOp - add handling for SHUFFLE(PSADBW(X,Y),PSADBW(Z,W)) -> PSADBW(SHUFFLE(X,Z),SHUFFLE(Y,W)) (#188072)
PSADBW takes vXi8 inputs and gives a vXi64 result so we need to tweak
the bitcasts (shuffle types checks will already ensure that the result
type isn't affected).

Minor improvement to #187447
2026-03-23 17:24:40 +00:00
Alan Zhao
c624851037
[LoopVectorize] Fix an integer narrowing conversion in getPredBlockCostDivisor(...) (#187605)
`LoopVectorizationCostModel::getPredBlockCostDivisor(...)` may return
large `uint64_t` values that get coerced to an `unsigned` by
`VPCostContext::getPredBlockCostDivisor(...)`, which can cause division
by zero.

Fixes #187584
2026-03-23 17:22:05 +00:00
Joshua Batista
54a3518fc3
[HLSL] Add WaveActiveBitAnd builtin function (#187149)
This PR adds the WaveActiveBitAnd HLSL function.
Fixes https://github.com/llvm/llvm-project/issues/99166
2026-03-23 10:19:18 -07:00
Sarah Spall
1aa64ff937
[HLSL] handle hlslAttributedResourceType in init list code (#187813)
Handle HLSL Attributed Resource Type in the init list code. Treat it
like its a scalar value.
Closes #187568
2026-03-23 10:16:39 -07:00
Théo Degioanni
239ca11a55
[MLIR][Mem2Reg] Add support for region control flow and SCF (#185036)
This PR adds support for region control-flow. Region control-flow and
CFG can be mixed together in the same program. See the [accompanying
RFC](https://discourse.llvm.org/t/rfc-support-region-control-flow-in-mem2reg/90082)
for some design considerations.

Beyond the considerations in the RFC, a few minor changes were
introduced:

- Calling the visitor hook for defined values is now deferred to the end
of promotion.
- The lazy creation of default values has been moved to the places where
it happens to prepare for a future change where it is actually lazy.
Documentation about it not working as intended for now was also added.

All SCF operations are supported, including `forall` and `parallel`,
which is pretty cool I think.

I am sorry in advance for git diff displaying a really bad diff for
Mem2Reg.cpp around where the liveness analysis used to be. Do consider
simply reading this part of the code off the file.

As a disclaimer, I designed all the test cases myself, but I used a
large amount of matrix multiplications to produce the corresponding IR
and FileCheck tests. I have reviewed them carefully and they correspond
to my intent.

---------

Co-authored-by: Slava Zakharin <szakharin@nvidia.com>
2026-03-23 18:08:55 +01:00
Anshil Gandhi
94239b3450
[AMDGPU][GlobalISel] Add RegBankLegalize rules for permlane16/permlanex16 (#187906)
Add RegBankLegalize rules for the amdgcn_permlane16
and amdgcn_permlanex16 intrinsics. Both intrinsics
are sources of divergence, so only the divergent
case is needed: result, old, and src0 map to VGPR,
while src1 and src2 are SGPR with ReadFirstLane if
divergent.

Update the GISEL RUN lines in llvm.amdgcn.permlane.ll
and permlane16_opsel.ll to use -new-reg-bank-select,
and regenerate check lines. The v8i16 test cases now
produce identical SDAG/GISEL output so their checks
are unified.
2026-03-23 16:58:05 +00:00
NeKon69
b32b31e6a7
[LifetimeSafety] Fix compiler crash with static operator() (#187853)
This PR removes the first argument from the `Args` list (which is `S()`)
before doing lifetime safety checks to ensure correct indexing.

It also adds a test to prevent regressions in the future

Fixes #187426
<details>
<summary>Bug details</summary>

When calling a `static operator()` directly (with `S()(...)`), we also
store `S()` in `Args` as the first argument, so all indexing is off by
one.
The most interesting part is that `S::operator()(...)` works correctly
and does not add `S()` at the beginning of the argument list, so it does
not crash during lifetime checks.
This solution is probably not the cleanest, but I would love to hear
feedback on where to put it!
</details>
2026-03-23 17:53:34 +01:00
Alexey Bataev
af37ac8aee [SLP]Use reduction root explicitly from reduction analysis to avoid non-determinism
Initially, the reduction root was detected using the last member of the UserIgnoreList set, which is unordered. Better to use the reduction root explicitly to avoid non-determinism in the reduction parent block, which may cause incorrect scale factor estimation for the reduction cost.
2026-03-23 09:46:33 -07:00
Jeff Bailey
079be4e739
[libc] Support Windows test executables in LibcTest lit format (#188057)
Updated LibcTest to handle Windows test executables:

* Added support for .exe extensions when identifying test executables.
* Skipped the executable bit check on Windows as it is not applicable.
* Updated .params file discovery to look for both <test>.exe.params and
<test>.params.

This allows running libc tests on Windows hosts.
2026-03-23 16:39:40 +00:00
Robert Konicar
da5d4214bc
[MLIR][TableGen] Make optional enum parser not consume the token when it is not matched (#188008)
Previously the optional parser would consume the token even when it
failed to match a value of the enum and prevented parsers later in the
op syntax from having an attempt. This PR changes that so that the token
is consumed only when the parsing succeeds. This change is made to the
emitted `FieldParser<std::optional<T>>` for enums.

This, for example, allows having a simple list of default valued props
in the assembly format without needing decorations around them. This
mimics the behaviour that is emitted for `DefaultValuedAttribute` when
it is used with `EnumAttr`.

This PR also adds `parseOptionalString` variant with an allow-list
argument as `parseOptionalKeyword` has and adds
`parseOptionalKeywordOrString` allow-list variant which combines these
two into a single utility wrapper. These methods do not consume the
token unless it is from the allow-list.
2026-03-23 17:33:49 +01:00
Austin Kerbow
3e4efe3ed4
[AMDGPU] Add ML-oriented coexec scheduler selection and queue handling (#169616)
This patch adds the initial coexec scheduler scaffold for machine
learning workloads on gfx1250.

It introduces function and module-level controls for selecting the
AMDGPU preRA and postRA schedulers, including an `amdgpu-workload-type`
module flag that maps ML workloads to coexec preRA scheduling and a nop
postRA scheduler by default.

It also updates the coexec scheduler to use a simplified top-down
candidate selection path that considers both available and pending
queues through a single flow, setting up follow-on heuristic work.
2026-03-23 09:30:01 -07:00
Jasmine Tang
d69c670934
[WebAssembly] Add initial shuffle cost capabilities (#187596)
Fixes #178940

Fixes the case of i16x8, i8x16 manual splat not recognized but the case of i32x4 still remains.
2026-03-23 09:28:37 -07:00
Timm Baeder
ada44b090b
[clang][bytecode] Avoid a macro redefinition (#188052)
Fixes:

```
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/AST/ByteCode/Interp.cpp:46:9: error: 'MUSTTAIL' macro redefined [-Werror,-Wmacro-redefined]
   46 | #define MUSTTAIL
      |         ^
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/AST/ByteCode/Interp.cpp:32:9: note: previous definition is here
   32 | #define MUSTTAIL [[clang::musttail]]
      |         ^
1 error generated.
```
2026-03-23 17:20:01 +01:00
vangthao95
27adb8f7ad
AMDGPU/GlobalISel: RegBankLegalize rules for exp_compr (#187822)
This intrinsic only accepts vectorTy. Correct the test to use v2s16.
2026-03-23 09:14:24 -07:00
Xinlong Chen
b670265b58
[DAG] ComputeKnownBits - set low bit to zero for ADD(X,X) (#186461)
ADD(X,X) is equivalent to SHL(X,1), so bit[0] is always zero.

This allows downstream folds like `and(add(x,x), 1) -> 0`.

Fixes #186091
2026-03-23 16:10:36 +00:00
vangthao95
0e0dc535d1
AMDGPU/GlobalISel: Use B32 for readfirstlane (#187809)
Using B32 would also add missing pointer support to readfirstlane
intrinsic rule.
2026-03-23 09:04:49 -07:00
Simon Tatham
44df4116c8
[compiler-rt][ARM] cmake properties for complicated builtin sources (#179919)
In the builtins library, most functions have a portable C implementation
(e.g. `mulsf3.c`), and platforms might provide an optimized assembler
implementation (e.g. `arm/mulsf3.S`). The cmake script automatically
excludes the C source file corresponding to each assembly source file it
includes. Additionally, each source file name is automatically
translated into a flag that lit tests can query, with a name like
`librt_has_mulsf3`, to indicate that a function is available to be
tested.

In future commits I plan to introduce cases where a single .S file
provides more than one function (so that they can share code easily),
and therefore, must supersede more than one existing source file.

I've introduced the `crt_supersedes` cmake property, which you can set
on a .S file to name a list of .c files that it should supersede. Also,
the `crt_provides` property can be set on any source file to indicate a
list of functions it makes available for testing, in addition to the one
implied by its name.
2026-03-23 16:01:12 +00:00
Folkert de Vries
b2edc0a3f8
wasm: recognize any_true and all_true (#155885)
fixes https://github.com/llvm/llvm-project/issues/129441

cc @lukel97 @badumbatish
https://github.com/llvm/llvm-project/pull/145108

I've been learning a bit about LLVM, trying to make progress on some of
these issues. The code below is based on
https://github.com/llvm/llvm-project/pull/145108#issuecomment-3004561085,
by implementing `shouldExpandReduction`.

The implementation works for the test cases I added, but (obviously)
fails for any existing cases. `ISD::VECREDUCE_AND` and
`ISD::VECREDUCE_OR` are now marked as legal, which is required for the
`Pat`s to fire, but when they don't that causes a selection failure.

So, I'm wondering, what is the right approach here. Should I mark these
intrinsics as `Custom` instead and manually perform the transformation
in C++? Or is there some trick to still get the default lowering (a
series of loads and scalar bitwise operations) when the patterns don't
fire?
2026-03-23 16:58:24 +01:00
Rahul Joshi
7fa2752a28
[NFC][Support] Minor code cleanup in APFloat.cpp (#187526)
Minor code cleanup: define variables at their first assignment as
opposed to at the start of functions, and use `[[maybe_unused]]` for
variables used in assert only.
2026-03-23 08:56:55 -07:00
Petar Avramovic
ce5a1dffa2
AMDGPU: Improve codegen for VOP2 v_dot2c_f32_f16/bf16 (#179225)
Select VOP2 version when there are no src_modifers, otherwise VOP3.
2026-03-23 16:55:53 +01:00
vangthao95
0748515784
AMDGPU/GlobalISel: RegBankLegalize rules for mov_dpp (#187807) 2026-03-23 08:53:30 -07:00