91199 Commits

Author SHA1 Message Date
Chinmay Deshpande
5ecc7e1e57
[AMDGPU][NFC] Update gating target feature for SWMMAC instructions (#190012) 2026-04-02 08:39:59 -07:00
Petar Avramovic
5226289b8e
Revert "AMDGPU: Codegen for v_dual_dot2acc_f32_f16/bf16 from VOP3" (#190159)
This reverts commit 47f6a19181b426baa03182ab6a7a41e16b35301d.
Breaks MIOpen, don't have propper fix yet.
2026-04-02 14:05:08 +00:00
Simon Pilgrim
7410a81fbd
[X86] LowerShiftByScalarImmediate - vXi8 shl(X,2) - prefer PADDB+PADDB pair over PSLLW+PAND (#186095)
For all targets, (V)PADDB is always as fast as (V)PSLLW (usually faster)
- and usually as fast as (V)PAND, and avoids having to load a mask - so
for shift lefts by 2, a pair of (V)PADDB is a better choice vs
(V)PSLLW+(V)PAND

This is only necessary if we're avoiding a (V)PAND mask - otherwise we
just need a single (V)PSLLW.
2026-04-02 12:48:18 +01:00
Valeriy Savchenko
f51e343ed5
[AArch64] Select REV16 for zext(bswap(i16)) (#189576)
Extend the existing any_extend(bswap i16) -> rev16 combine to also
handle zero_extend. REV16 preserves a zero upper half, so for i16 loads
this saves one instruction: ldrh+rev+lsr#16 -> ldrh+rev16.
2026-04-02 11:32:39 +01:00
Ricardo Jesus
9ff2ef9711
[AArch64][SVE] Define pseudos for arithmetic immediate instructions. (#188579)
This patch uses DestructiveBinaryShImmUnpred (which was previously
unused as far as I could tell) to define pseudos for arithmetic
immediate instructions such as ADD (immediate), which allows using
MOVPRFX with these instructions.
2026-04-02 11:07:46 +01:00
Elvis Wang
81691d23cd
[RISCV][TTI] Update cost and prevent exceed m8 for vector.extract.last.active (#188160)
This patch contains two parts.
1. Update costs reflect to the codegen changes. This is not that
accurate since the step vector can use smaller type if there is a
vscale_range attribute. But we cannot get that in the type-based query
in TTI.
2. Return invalid cost for the vector.extract.last.active that needs
vector split for the step vector. But currently this is not handled
correctly and will hit the assertion.

For not blocking the FindLast reduction in LV
(https://github.com/llvm/llvm-project/pull/184931). We should land this
first and fix the SelectionDAG for vector.extract.last.active lowering.
2026-04-02 16:49:05 +08:00
Sander de Smalen
703d43ca3b
[CostModel] Move default expand cost for partial reductions to BasicTTIImpl (#189905)
This is a follow-up of the suggestion left here:

https://github.com/llvm/llvm-project/pull/181707#discussion_r2995733831

The override functions in AMDGPU/ARM/SystemZ/X86 are required to avoid
enabling partial reductions where they were previously disabled (I've
added this for all targets that implement getArithmeticReductionCost).
2026-04-02 09:42:53 +01:00
David Green
083f9c158a
[AArch64][GISel] Widen non-power2 element sizes for ctlz. (#189371)
This addresses an illegal mutation kind, where gisel would hit an
assert. It expands vector elements for non-power2 elements or elements
less that i8 to a power of 2.

A fix to handle vector types correctly was needed in LegalizerHandler.

Fixes #185411
2026-04-02 07:27:12 +01:00
Craig Topper
68cbcf7ec2
[RISCV] Check EnsureWholeVectorRegisterMoveValidVTYPE in RISCVInsertVSETVLI::transferBefore. (#190022)
Fixes #189786
2026-04-01 23:14:38 -07:00
Luke Lau
2a7ca3a3fa
[RISCV] Remove codegen for vp_ctlz, vp_cttz, vp_ctpop (#189904)
Part of the work to remove trivial VP intrinsics from the RISC-V
backend, see
https://discourse.llvm.org/t/rfc-remove-codegen-support-for-trivial-vp-intrinsics-in-the-risc-v-backend/87999

This splits off 3 intrinsics from #179622.

Note that vp.cttz is the elementwise version, not vp.cttz.elts.
2026-04-02 05:26:41 +00:00
Diego Novillo
06aae40c6d
[HLSL][SPIRV] Restore support for -g to generate NSDI (#190007)
The original attempt (#187051) produced a regression for
`intel-sycl-gpu` because `SPIRVEmitNonSemanticDI` will now self-activate
whenever `llvm.dbg.cu` is present. This removed the need for the
explicit `--spv-emit-nonsemantic-debug-info` flag.

The pass is now entered unconditionally for all SPIR-V targets, but
`NonSemantic.Shader.DebugInfo.100` requires the
`SPV_KHR_non_semantic_info`. Targets like `spirv64-intel` do not enable
that extension by default. When `checkSatisfiable()` ran on those
targets, it issued a fatal error rather than silently skipping.

Adds an early-out from `emitGlobalDI()`: if
`SPV_KHR_non_semantic_info` is not available for the current target, the
pass returns without emitting anything.
2026-04-01 21:00:36 -07:00
Sudharsan Veeravalli
18a065763d
[RISCV] Move unpaired instruction back in RISCVLoadStoreOptimizer (#189912)
There are cases when the `Xqcilsm` vendor extension is enabled that we
are unable to pair non-adjacent load/store instructions. The
`RISCVLoadStoreOptimizer` moves the instruction adjacent to the other
before attempting to pair them but does not move them back when it
fails. This can sometimes prevent the generation of the `Xqcilsm`
load/store multiple instructions. This patch ensures that we move the
unpaired instruction back to it's original location.
2026-04-02 09:18:58 +05:30
Simon Pilgrim
c8c7186b46
[X86] LowerRotate - expand vXi8 non-uniform variable rotates using uniform constant rotates (#189986)
We expand vXi8 non-uniform variable rotates as a sequence of uniform
constant rotates along with a SELECT depending on whether the original
rotate amount needs it

This patch removes premature uniform constant rotate expansion to the
OR(SHL,SRL) sequences to allow GFNI targets to use single VGF2P8AFFINEQB
calls
2026-04-02 02:30:59 +00:00
Anshul Nigham
dee982d6c8
[NewPM] Adds a port for AArch64PostCoalescerPass (#189520)
Adds a standard porting for AArch64PostCoalescer to NewPM.
2026-04-01 19:18:18 -07:00
Anshul Nigham
e27e7e4339
[NFC][AAarch64] Remove PreLegalizerCombiner pass dependency on TargetPassConfig (#190073)
This will enable NewPM porting.

Replaced with the definition in
[AArch64PassConfig::getCSEConfig](1d549d9a77/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (L614))
2026-04-01 19:09:37 -07:00
Jim Lin
3d7eedce56
[RISCV] Fix stackmap shadow trimming NOP size for compressed targets (#189774)
The shadow trimming loop in LowerSTACKMAP hardcoded a 4-byte decrement
per instruction, but when Zca is enabled NOPs are 2 bytes. Use NOPBytes
instead of the hardcoded 4 so the shadow is correctly trimmed on
compressed targets.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 08:21:33 +08:00
Jim Lin
b9e01c26f0
[RISCV] Relax VL constraint in convertSameMaskVMergeToVMv (#189797)
When converting a PseudoVMERGE_VVM to PseudoVMV_V_V, we previously
required MIVL <= TrueVL to avoid losing False elements in the tail.

Relax this constraint when the vmerge's False operand equals its
Passthru operand and the True instruction's tail policy is TU
(tail undisturbed). In this case, True's tail lanes preserve its
passthru value (which equals False and Passthru), so the conversion
is safe even when MIVL > TrueVL.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:12:48 +08:00
Demetrius Kanios
29391328ab
[WebAssembly][GlobalISel] CallLowering lowerFormalArguments (#180263)
Implements `WebAssemblyCallLowering::lowerFormalArguments`

Split from #157161
2026-04-01 16:12:38 -07:00
Craig Topper
7d24b175eb
[RISCV] Add SATI_RV64/USATI_RV64 to RISCVOptWInstrs. (#190030)
Note the immediates for these 2 instructions in their MachineInstr
representations both use the type width. The SATI_RV64 binary encoding
and the RISCVISD::SATI encoding uses the type width minus one.

Assisted-by: Claude Sonnet 4.5
2026-04-01 14:38:11 -07:00
Stanislav Mekhanoshin
a9df7c7186
[AMDGPU] True16 support for bf16 clamp pattern on gfx1250 (#190036) 2026-04-01 14:26:42 -07:00
Luke Lau
07fc9b8155
[RISCV] Remove codegen for vp_minnum, vp_maxnum (#189899)
Part of the work to remove trivial VP intrinsics from the RISC-V
backend, see
https://discourse.llvm.org/t/rfc-remove-codegen-support-for-trivial-vp-intrinsics-in-the-risc-v-backend/87999

This splits off 2 intrinsics from #179622.
2026-04-01 17:40:04 +00:00
Mirko Brkušanin
5d9eb0c76a
[AMDGPU] Define new targets gfx1171 and gfx1172 (#187735) 2026-04-01 18:16:11 +02:00
Craig Topper
16255e457c
[RISCV] Add RISCVISD::USATI/SATI to computeKnownBitsForTargetNode/ComputeNumSignBitsForTargetNode. (#189702) 2026-04-01 09:02:19 -07:00
Craig Topper
364b19322d
[RISCV] Add assertions to VSETVLIInfo::hasSEWLMULRatioOnly(). NFC (#189799)
Ensure that we can only call this on valid and not unknown.
2026-04-01 09:01:26 -07:00
zGoldthorpe
6f0e961cc2
[WebAssembly] Correct operands for NaN/Zero checks in min/max (#189712)
The `pmin` and `pmax` pattern fragments match `vselect`s, meaning that
the generated operands for `relaxed_min` and `relaxed_max` correspond to
operands 1 and 2 of the `vselect` (rather than operands 0 and 1).
2026-04-01 15:54:36 +00:00
Lei Huang
697ff31fc7
[PowerPC] Enhance vec_rl() to generate xvrlw (#189023)
Enhance existing builtin vec_rl() to generate the new xvrlw, VSX version
of vrlw, for cpu=future.
2026-04-01 11:38:43 -04:00
Steven Perron
9dc8f465a4
[SPIRV] Implement the int_spv_resource_calculate_lod* IntrinsicsSPIRV (#188337)
Implements intrinsics used to get the level-of-detail given a texture,
sampler, and a coordinate. It will be used to implement the
corresponding HLSL methods.

Assisted-by: Gemini
2026-04-01 14:03:42 +00:00
Pankaj Dwivedi
86c3abe85e
[NFC] Rename InstructionUniformity to ValueUniformity (#189935) 2026-04-01 19:28:33 +05:30
Rahul Joshi
5781cc9bf6
[LLVM][Intrinsics] Refactor IIT encoding generation (#189790)
Refactor IIT encoding generation. The core change here is that when
generating IIT encodings, we pre-generate all the bits of the IIT
encoding except cases where a type needs to encode its own overload
index, which is patched in later in `TypeInfoGen`. In addition, this
change introduces a class hierarchy for dependent types, so that the
checks in `TypeInfoGen` are more meaningful, and renames/simplifies
several other pieces of code, as listed below.

1. Change the encoding for IIT_ARG's ArgInfo byte to encode the overload
slot index in lower 5 bits and the argument kind in upper 3 bits. This
enabled generating the same packed format for all other dependent types
that need to encode an overload slot index in the IIT encoding. Adjusted
the corresponding C++ code in `IITDescriptor::getArgumentNumber` and
`IIT_Descriptor::getArgumentKind`.
2. Introduce more descriptive classes to handle packing of the overload
index + arg kind into the IIT encoding. `OverloadIndexPlaceholder` is
used to generate a transient value in the type-signature that is patched
in `TypeInfoGen` with that type's overload index. `PackOverloadIndex` is
used to encapsulate the final packing of an overload index and argument
kind in a single byte, and `PatchOverloadIndex` is the class that does
the required patching of a `OverloadIndexPlaceholder` given the type's
overload index.
3. Delete `isAny`, `ArgCode` and `Number` from base `LLVMType` class.
Replace use of `isAny` with `isa<LLVMAnyType>`, `ArgCode` is not used
anymore, and move `Number`, which was used to represent the overload
index for a dependent type to the `LLVMDependentType` class and rename
it to `OverloadIndex`.
4. Introduce `LLVMDependentType` as a base class of all dependent types.
It holds the overload index of the type it depends on in its
`OverloadIndex` field. Also introduce 2 subclasses,
`LLVMFullyDependentType` to represent all fully dependent types (which
encode just the appropriate IIT code and the dependent type's overload
index) and `LLVMPartiallyDependentType` to represent partially dependent
types, that encode the appropriate IIT code and both this type's
overload index and the dependent type's overload index.
5. Change existing dependent type classes to derive from one of these
classes and rename the `num` class argument to `oidx` to better reflect
its meaning.
6. Rename various fields and classes used in `TypeInfoGen` to be more
meaningful. `AssignOverloadIndex` to do overload index assignment,
rename `ACIdxs` to `OverloadIdxs`, `ACTys` to `OverloadTypes` and use
the `DoPatchOverloadIndex` to patch in assigned overload slot indexes.
2026-04-01 06:39:36 -07:00
Gergo Stomfai
15d48c5bbe
[X86][DAG] remove LowerFCanonicalize (#188127)
Remove LowerFCanonicalize. Added fallback for cases when the scalar type also has its Custom lowering to avoid regressions on AMDGPU and SystemZ.

Fixes #143862
2026-04-01 13:34:05 +00:00
Sergio Afonso
2cff995e91
[AMDGPU] Fix crash with dead frame indices in debug values (#183297)
When spill slots are eliminated (VGPR-to-AGPR, SGPR-to-VGPR lanes),
debug values referencing these frame indices were not always properly
cleaned up. This caused an assertion failure in getObjectOffset() when
PrologEpilogInserter tried to access the offset of a dead frame object.

The existing debug fixup code in SIFrameLowering and SILowerSGPRSpills
had two limitations:
1. It only checked one operand position, but DBG_VALUE_LIST instructions
can have multiple debug operands with frame indices.
2. It didn't handle all types of dead frame indices uniformly.

Fix by centralizing debug info cleanup in removeDeadFrameIndices(),
which already knows all frame indices being removed. This iterates over
all debug operands using MI.debug_operands().

Assisted-by: Claude Code.
2026-04-01 13:41:53 +01:00
Manuel Carrasco
ab4b689258
[AMDGPU][SIFoldOperands] Fix OR -1 fold (#189655)
In SIFoldOperands, folding `or x, -1` to `v_mov_b32 -1` removed
`Src1Idx`, which is incorrect because `-1` is in `Src0Idx` (after
canonicalization).

Closes https://github.com/llvm/llvm-project/issues/189677.
2026-04-01 13:37:37 +01:00
Nikita Popov
d14888121d
[Mips] Correctly report sizes for PATCHABLE_* (#188229)
Report the size of the xray sled.

This came up while working on
https://github.com/llvm/llvm-project/pull/187703.
2026-04-01 14:35:07 +02:00
Arseniy Obolenskiy
69b116d075
[SPIR-V] Fix OpVectorExtractDynamic operand type (#189635)
vID is a register class for integer vector registers only. vfID (float
vector registers) should be also accepted. Aligning the definition with
other instructions of this kind

related to #188703
2026-04-01 14:29:45 +02:00
Luke Lau
effcd181e5
[RISCV] Remove codegen for VP float rounding intrinsics (#189896)
Part of the work to remove trivial VP intrinsics from the RISC-V
backend, see
https://discourse.llvm.org/t/rfc-remove-codegen-support-for-trivial-vp-intrinsics-in-the-risc-v-backend/87999

This splits off seven intrinsics from #179622.

We now generate vfcvt.rtz for llvm.vp.roundtozero. It looks like we
should have been using the codegen for llvm.trunc for it, but we somehow
missed that.
2026-04-01 11:04:53 +00:00
Jonathan Thackray
d6cd15901a
[AArch64][llvm] Gate some tlbip insns with either +tlbid or +d128 (#178913)
Change the gating of `tlbip` instructions (`sysp` aliases) containing
`*E1IS*`, `*E1OS*`, `*E2IS*` or `*E2OS*` to be used with `+tlbid` or
`+d128`. This is because the 2025 Armv9.7-A MemSys specification says:

```
  All TLBIP *E1IS*, TLBIP *E1OS*, TLBIP *E2IS* and TLBIP *E2OS*
  instructions that are currently dependent on FEAT_D128 are updated
  to be dependent on FEAT_D128 or FEAT_TLBID
```

See also change #178912 where the gating of `+d128` for `sysp` was
removed.
2026-04-01 11:24:33 +01:00
Daniil Fukalov
6bf794a02a
[AMDGPU] Disable generic DAG combines at -O0 to preserve debuggability. (#176304)
Disable generic DAG combines for AMDGPU at -O0 via
disableGenericCombines() to preserve instructions that users may want to
set breakpoints on during debugging.

Assisted-by: Cursor / Claude Opus 4.6
2026-04-01 11:55:17 +02:00
lrzlin
5651490992
[LoongArch] Implement canMergeStoresTo to avoid crash while NoImplicitFloat attribute is set (#188005)
Currently, when the `NoImplicitFloat` attribute is set, consecutive
64-bit load
and store operations will be combined into 128-bit ones, which is
illegal
because that attribute makes floating point and SIMD unavailable. 
By implementing the canMergeStoresTo, we can prevent this incorrect
merging.

Fixes https://github.com/llvm/llvm-project/issues/186645
2026-04-01 17:05:01 +08:00
David Green
eeb2fae5c0
[AArch64][GISel] Do not bitcast nonpower2 element size G_CONCATs (#189911)
This currently gets stuck in a loop, unable to make progress throught
the
bitcast concat. Limit it to legal element sizes so that we always make
progress
and at least fall back to SDAG as opposed to crashing or getting stuck.
2026-04-01 09:26:45 +01:00
Luke Lau
1d549d9a77
[RISCV] Remove codegen for vp_lrint, vp_llrint (#189714)
Part of the work to remove trivial VP intrinsics from the RISC-V
backend, see
https://discourse.llvm.org/t/rfc-remove-codegen-support-for-trivial-vp-intrinsics-in-the-risc-v-backend/87999

This splits off two intrinsics from #179622.

We need to use the other intrinsic constructor in
ExpandVectorPredication.cpp because llrint has multiple overloaded types
2026-04-01 06:46:38 +00:00
Craig Topper
512071941d
[RISCV] Add codegen support for SATI and USATI. (#189532)
Implementation is largely based on ARM which has similar instructions.
2026-03-31 22:23:10 -07:00
Craig Topper
2b98f7fc3d
[RISCV] Slightly optimize insertVSETMTK. NFC (#189771)
Sink the hasTKOp and hasTMOp checks into the switch.
2026-03-31 18:12:48 -07:00
Craig Topper
2f8c0cbac0
[RISCV] Use a switch default+llvm_unreachable instead of an assert. NFC (#189770) 2026-03-31 18:12:32 -07:00
Henry Jiang
bf50489eeb
[Psuedoprobe][MachO] Enable pseudo probes emission for MachO (#185758)
Enable pseudo probes emission for MachO. Due to the 16 character limit
of MachO segment and section, the file sections will be
`__PSEUDO_PROBE,__probes` and `__PSEUDO_PROBE,__probe_descs`.
2026-03-31 16:27:58 -07:00
Craig Topper
c9bc317d6d
[RISCV][P-ext] Support i32 ushlsat on RV32. (#189730)
We have a sshl instruction on RV32 in the 0.21 spec. Unfortunately,
we don't have a SSLLI instruction, but we can put a constant shift
amount in a register.
2026-03-31 15:26:08 -07:00
Craig Topper
f2f54b6874
[RISCV][P-ext] Support i32 avgfloors/avgflooru on RV32. (#189736) 2026-03-31 15:01:02 -07:00
Craig Topper
6e82a24f4c
[RISCV][P-ext] Rename simm8_unsigned/simm10_unsigned used PLUI/PLI. NFC (#188808)
Replace unsigned with plui or pli_b to better indicate their usage.

Templatize the render function and rename it addSExtImm instead of
addSImm*Unsigned.
2026-03-31 14:48:17 -07:00
Arseniy Obolenskiy
c97561ced1
[SPIR-V] Derive FPFastMathMode from nofpclass attributes on OpenCL builtins (#188984) 2026-03-31 22:25:22 +02:00
Demetrius Kanios
de84be21ec
[WebAssembly][GlobalISel] G_ADD (and in-reg ext/trunc related) legalization & selection (#183694)
This PR enables `G_ADD` and immediate dependencies (relavent ext and
trunc related ops) to be fully legalized and selected.

The most important change made is getting the boilerplate for
RegBankSelect working.

Split from #157161.
2026-03-31 12:20:08 -07:00
Laxman Sole
da173bfbf5
[NVPTX] Do not emit .debug_pubnames and .debug_pubtypes for NVPTX backend (#187328)
This change adds a mechanism to stop emitting `.debug_pubname`,
`.debug_pubtypes` sections for a particular target.

This is particularly useful for cases where IR is generated by frontends
that do not explicitly disable these sections (as `Clang` does for
`NVPTX`), but still use `llc` for code generation.

Currently, only `NVPTX` uses this to disable these sections.
2026-03-31 12:13:39 -07:00