[RISCV] Fix unintentional overlap in RVVTypeCache::computeTypes. (#245839)
The TM field was changed from uint8_t to uint16_t when the AltFP8 bit
was added in June.
[VectorUtils] Recognize scalar-condition selects of splats (#245362)
`isSplatValue` required the condition of a `select` to be a splat as
well, so it rejected
```llvm
select i1 %c, <8 x i1> splat (i1 true), <8 x i1> zeroinitializer
```
although a scalar condition picks a whole operand. Only require a vector
condition to be a splat.
MLIR lowers the row masks of 2-D masked vector reads to this form,
including masks from the Linalg vectorizer. `ScalarizeMaskedMemIntrin`
uses its single-branch path (#104537) only for splat masks, so on NVPTX
these loads and stores were expanded lane by lane.
With this change each row becomes one conditional vector access: with a
known alignment, rows are loaded with `LDG.E.128` instead of scalar
[38 lines not shown]
[AMDGPU][GlobalISel] Use v_cmpx/s_andn2_wrexec form in RegBankLegalize waterfall loops
Port the UseNewExecInstructions path from SIInstrInfo's waterfall emission
to RegBankLegalizeHelper::executeInWaterfallLoop. On subtargets with
no-sdst v_cmpx and s_andn2_wrexec, the loop now narrows exec with deferred
V_CMPX_EQ_*_nosdst_e32_term compares and computes the remaining lanes with
S_ANDN2 from an exec PHI, written back by S_MOV_term. SIOptimizeExecMasking
then folds the pair into s_and_not1_wrexec, matching SelectionDAG.
Co-authored-by: Cursor <cursoragent at cursor.com>
[mlir][vector] Do not emulate narrow-type masked Xfer reads (#244883)
`ConvertVectorTransferRead` ignores the mask.
Under `vector.mask`, the new ops are created inside the mask region,
which yields invalid IR.
The pattern now bails out on masked reads.
Supporting them is left as future work.
Part of #239511, as it unifies the behavior of masks.
RFC:
https://discourse.llvm.org/t/rfc-unify-masking-in-the-vector-dialect/92675
---------
Signed-off-by: Federico Bruzzone <federico.bruzzone.i at gmail.com>
[Sparc] Add a SPARC TargetParser generated from Sparc.td (#245165)
Like PowerPC, split the subtarget features and processor definitions
out of Sparc.td into SparcFeatures.td and SparcProcessors.td, and
generate the CPU and feature tables for the TargetParser from them
with -gen-target-features.
Use it for the backend's default CPU, and in Clang for the list of
valid CPUs and each CPU's default features, instead of keeping a
separate CPU table in Clang. initFeatureMap() now starts from the
CPU's default features, and handleTargetFeatures() records V9, LEON
and LEON CASA support from the resulting feature list.
Clang now accepts every CPU the backend knows about, adding generic,
v7, myriad2, myriad2.1, myriad2.2 and myriad2.3. The Myriad 2 CPUs
now also define __leon__, as the backend treats them as LEON CPUs.
V7 does not get the V8 macros (__sparcv8, __sparcv8__ and
__sparc_v8__), as it lacks the integer multiply and divide
[2 lines not shown]
[AMDGPU] Add MFMA co-exec rows for gfx942 MFMAs
Add MFMA co-exec rows for gfx942 MFMAs for both gfx942 and gfx950.
Gfx950 support gfx942 mfma opcodes as well as others.
Add rows for:
XDL_2Pass:
v_mfma_f32_4x4x4_16b_{f16,bf16}
v_mfma_i32_4x4x4_16b_i8
XDL_4Pass:
v_mfma_f32_16x16x16_{f16,bf16}
v_mfma_i32_16x16x32_i8
v_mfma_f32_16x16x8_xf32 (gfx942 only)
v_mfma_f32_16x16x32_{bf8,fp8}_{bf8,fp8}
XDL_8Pass:
v_mfma_f32_16x16x4_4b_{f16,bf16}
[44 lines not shown]
[AMDGPU] Precommit legacy MFMA co-exec tests (NFC)
Add coexec scheduler cases for a gfx940 SMFMAC
(v_smfmac_f32_16x16x32_f16) on gfx950 and for a DGEMM
(v_mfma_f64_16x16x4_f64) on gfx942 and gfx950, a gfx942 RUN line in
coexec-sched-warning.mir, and unit test rows for one MFMA per legacy
variant on gfx950 plus v_mfma_f64_16x16x4_f64 on gfx942.
The legacy variants fall back to a permissive window that lets anything
co-execute. v_mfma_f64_16x16x4_f64 uses its gfx950 rule on gfx942 as
well, and gfx942 does not enable the co-exec model yet, so it warns and
its scheduler case runs without the model.
Assisted-by: Claude Opus 5.5
[Mips] Always use GPRs for $0-$31 inline asm register constraints (#244995)
An inline asm operand bound to $0-$31 (e.g. a local register variable
declared with asm("$8")) picked its register class with getRegClassFor()
on the operand type and then indexed that class by the register number.
This crashed for types with no native register class (i1, i8, i16, and
i64 on 32-bit targets), put float and double operands in FPRs ($8 became
$f8 for float and $f16 for double), and picked the wrong register in
MIPS16 mode, where the i32 class does not start at $0 ($2 became $4).
$0-$31 always name GPRs, so use GPR32 or GPR64 directly, like the 'r'
constraint does.
Fixes #243034
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Fix gfx950/gfx942 TRANS co-execute slot
On gfx950/gfx942, fix TRANS co-exec slot to be same as VALU.
Excluded from this commit:
TRANS on gfx950 (in unit of hardware cycle):
Reciprocal throughput (per SIMD):
f32/f16: 8
f64: 16
Def-to-use latency:
f32/f16: 12 to a non-TRANS reader, 8 to a TRANS reader
f64: 20 to a non-TRANS reader, 16 to a TRANS reader
Blocks this wave's issue for:
f32/f16: 8
f64: 16
On gfx942, f32/f16 have the same numbers as f64 above.
Currently, GCNHazardRecognizer inserts the correct s_nop between a TRANS
[5 lines not shown]
[AMDGPU] Precommit TRANS co-exec tests (NFC)
Add a gfx950 coexec scheduler case where a v_exp_f32 and a v_add_f32
compete for the window of an XDL2x (v_mfma_f32_16x16x32_bf16) MFMA.
No MFMA row allows TRANS so far, so the v_exp_f32 issues after the
MFMA window.
Assisted-by: Claude Opus 5.5
[AMDGPU] Fix gfx950/gfx942 v_pk f32 instr co-exec slot
On gfx950/gfx942, v_pk f32 instrs can issue only after the MFMA's own
cycles (in hardware cycles):
XDL/SMFMAC: 8 cycles
XDL2x/SMFMAC2x: 12 cycles
SGEMM/DGEMM: 8 cycles
Currently they are categorized as VALU. This is wrong for
XDL/SMFMAC/XDL2x/SMFMAC2x, since VALU can issue within the MFMA's own
cycles.
Fix this by adding a PK_F32 CoExecMask bit, a PK_F32 slot in each MFMA
row, and a PackedF32VALU InstructionFlavor. Classify the following
instrs as PackedF32VALU on gfx942/gfx950:
V_PK_{ADD,FMA,MUL}_F32, V_PK_MOV_B32.
NFC for gfx1250.
[3 lines not shown]
[AMDGPU] Precommit packed F32 co-exec tests (NFC)
Add a gfx950 coexec scheduler case where a v_pk_add_f32 and a v_add_f32
compete for the window of an XDL2x (v_mfma_f32_16x16x32_bf16) MFMA, and
a unit test for the co-execution class of the packed F32 instructions
and v_pk_add_f16. Packed F32 VALU is treated as plain VALU so far.
Assisted-by: Claude Opus 5.5
[mlir][vector] Do not hoist masked Xfers as plain subset extractions (#244557)
`-loop-invariant-subset-hoisting` treats a masked `vector.transfer_read`
as a plain subset extraction. However, a masked Xfer doesn't access its
whole slice.
With this PR the `SubsetOpInterface` returns `failure` for the slice and
answers _not equivalent_ and _not provably disjoint_, so the pass leaves
it in the loop.
Part of #239511.
RFC:
https://discourse.llvm.org/t/rfc-unify-masking-in-the-vector-dialect/92675
---------
Signed-off-by: Federico Bruzzone <federico.bruzzone.i at gmail.com>
[AMDGPU] Fix gfx950 MFMA co-exec rows for XDL2x_8Pass, SMFMAC2x, DGEMM
Fix the co-exec rows for the following instructions:
XDL2x_8Pass:
v_mfma_f32_32x32x16_f16
v_mfma_f32_32x32x16_bf16
v_mfma_i32_32x32x32_i8
v_mfma_f32_32x32x64_f8f6f4 and v_mfma_scale_f32_32x32x64_f8f6f4
with no fp8/bf8 operand
SMFMAC2x_4Pass:
v_smfmac_f32_16x16x64_f16
v_smfmac_f32_16x16x64_bf16
v_smfmac_i32_16x16x128_i8
v_smfmac_f32_16x16x128_{bf8,fp8}_{bf8,fp8}
SMFMAC2x_8Pass:
v_smfmac_f32_32x32x32_f16
[8 lines not shown]
[AMDGPU] Precommit gfx950 MFMA co-exec row tests (NFC)
Add a gfx950 coexec scheduler case for v_smfmac_f32_16x16x64_f16, and a
unit test that checks the first co-exec stage of SALU, DS and VMEM, VALU
and the next MFMA for one MFMA per gfx950 variant.
Assisted-by: Claude Opus 5.5
[WebAssembly] Declare command line options in TableGen (#245068)
Move the options into WebAssemblyOptions.td. LowerEmscriptenEHSjLj has
no TargetMachine and reads them from the module's LLVMContext; other
code reads them through the target machine or subtarget.
-wasm-disable-ehpad-sort is renamed to -wasm-ehpad-sort, with the old
spelling kept as an alias. -enable-emscripten-sjlj, -wasm-enable-sjlj,
-wasm-use-legacy-eh, and -emscripten-cxx-exceptions-allowed are now
listed by -help-hidden instead of -help.
Aided by Opus 5.5
[SandboxVec][BundleVec] Fix pass return value (#245794)
The IR may have changed even if vectorization failed, so this patch
makes sure we revert in that case. This used to cause a crash in
EXPENSIVE_CHECKS.
Same as https://github.com/llvm/llvm-project/pull/245693 but for
BundleVec.
[RISCV][GlobalISel] Expand FP round without Zfa (#244134)
Without Zfa these were lowered to libcalls, and f16 had no action at all so
llvm.ceil.f16 failed to legalize. Emit G_FROUND instead, so the PseudoFROUND
patterns are imported and emitFROUND does the guarded integer round trip for
both selectors. G_FNEARBYINT and rv32 f64 keep the libcall, since the round
trip raises inexact and rv32 has no 64-bit GPR.
[AMDGPU][GlobalISel] Use v_cmpx/s_andn2_wrexec form in RegBankLegalize waterfall loops
Port the UseNewExecInstructions path from SIInstrInfo's waterfall emission
to RegBankLegalizeHelper::executeInWaterfallLoop. On subtargets with
no-sdst v_cmpx and s_andn2_wrexec, the loop now narrows exec with deferred
V_CMPX_EQ_*_nosdst_e32_term compares and computes the remaining lanes with
S_ANDN2 from an exec PHI, written back by S_MOV_term. SIOptimizeExecMasking
then folds the pair into s_and_not1_wrexec, matching SelectionDAG.
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU] Describe MFMAs with a variant in MAIInstInfoTable (NFC)
- Add an MFMAVariant enum. Each MFMA pseudo gets its variant from
MAIInstInfoTable, a TableGen GenericTable. Each real MFMA opcode
inherits the variant of its pseudo through VOP3P_Real.
- Look up an MFMA's co-execution info by its variant, as gfx1250 does
for WMMA, instead of matching every opcode.
- Replace the is_dgemm and is_gfx940_xdl fields with the variant.
- Describe each MFMA row by the first stage at which SALU, memory, VALU
and the next MFMA may issue, plus the window length.
Assisted-by: Claude Opus 5.5
[AMDGPU] Exclude real V_ACCVGPR_READ/WRITE_B32_vi opcodes from isMFMA
Currently, only pseudo V_ACCVGPR_{READ,WRITE}_B32_e64 is excluded, fix
by also exclude real V_ACCVGPR_READ/WRITE_B32_vi.
[orc-rt] Make AllocAction APIs noexcept (#245814)
Allocation actions report failure via their result (as an out-of-band
error), and should not throw. Mark them noexcept.