[mlir][LLVM] Include LLVM dialect partition headers instead of LLVMDialect.h (#242307)
Most includers of `LLVMDialect.h` use only a few LLVM dialect ops, or
none at all, but still pay for all 323 op declarations. Widely included
headers such as `OpenMPDialect.h`, `NVVMDialect.h` and `GPUCommonPass.h`
include it as well, spreading the cost to TUs that never use the LLVM
dialect.
Building on #242301, this patch makes every file include what it uses:
the partition headers of the ops it uses, `LLVMDialectDecl.h`,
`LLVMTypes.h`, `LLVMAttrs.h` or `LLVMInterfaces.h` if it only uses the
dialect, types, attributes or interfaces, and forward declarations where
a declaration suffices. Headers no longer include LLVM dialect headers
on behalf of their includers. Files that use ops from at least 8 of the
14 partitions keep `LLVMDialect.h`.
This reduces the TUs including `LLVMDialect.h` in an MLIR, flang and CIR
build from 386 to 41. Downstream code that relied on getting LLVM
dialect ops transitively has to include the partition headers it needs.
[18 lines not shown]
[X86] PALIGNR/PSHLDQ/PSRLDQ/VPERM2X128 targets shuffles never create undef/poison (#243806)
Add missing target shuffles that all hit
isGuaranteedNotToBeUndefOrPoisonForTargetNode in existing lit-tests to
help smoke out remaining FREEZE regressions for #243178 / #152107 etc.
[lldb] Don't re-run XFAILed tests (#243492)
Re-running tests that are expected to fail does not give useful signal.
This patch makes it so that they don't re-run.
[mlir][tosa]Check for non tensor type and fail gracefully (#243805)
Following error report
[llvm-project#236561](https://github.com/llvm/llvm-project/issues/236561)
added check for non tensor output type in TOSA block scaled type
verification.
Signed-off-by: Philip Wilkinson <philip.wilkinson at arm.com>
[CIR] Use `cir.vec.fcmp` op for all fp vector comparisons (#241348)
Also removes support for floating point vectors from `cir.vec.cmp` op.
Claude helped with test updates.
[X86] Fix Lunar Lake ROB/RS sizes and FP ops on integer ports (#242473)
Address the data issues in X86SchedLunarlakeP.td reported in #209145:
- MicroOpBufferSize: the Lion Cove ROB has 576 entries.
- The integer scheduler has 120 reservation stations.
- (V)ADDSSrr/(V)SUBSSrr(_Int) use WriteFAdd: V2/V3, latency 2.
- (V)PALIGNRrri, VPALIGNRYrri and xmm VPBROADCAST{B,D,Q,W}rr run on the
vector shuffle ports V2/V3.
Measured on a Core Ultra 7 258V P-core with perf and
VEC_DISPATCHED.V0-V3: addss/subss (SSE and VEX) latency 2, 1 uop on
V2/V3, 0.5 cycles throughput; palignr/vpbroadcast xmm latency 1, 1 uop
on V2/V3, 0.5 cycles throughput. The model now matches both.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[mlir][SPIR-V] Require matching types in GroupNonUniform arithmetic ops (#243773)
The spec requires Value to have the same type as Result Type, but the
shared op definition accepted mismatched types such as i32 -> i64
[AMDGPU] Preserve noclobber after acquire operations from a different addrspace
Follow-up to #219991 to address reviewer comments:
AMDGPUAnnotateUniformValues should annotate uniform global loads as
`!amdgpu.noclobber` if the memory they are reading is never clobbered (since
kernel launch) before the load is executed.
PR #219991 strengthened the logic to consider acquire operations before the
load as clobbering (because they cause stores from other threads to be observed
by the load without a data race).
This PR weakens this criterion to ignore acquire operations that don't affect
the global address space (because they don't affect what the load in question
may or may not see). This addresses the performance-relevant case of s_barriers
with LDS-only fences.
The logic is still overly pessimistic for one-as load acquires, they could also
be ignored when looking for clobbering operations.
Disclaimer: Claude gave review comments and suggestions that I addressed during
[5 lines not shown]
Put the toSIAtomicAddrSpace logic into a table and make it consistent with isExtendedGlobalAddrSpace
With that, the change is no longer NFC, since constant addrspaces and
addrspaces above `MAX_AMDGPU_ADDRESS` now map to `SIAtomicAddrSpace::GLOBAL`
instead of `OTHER`. This means that atomics on these addrspaces are no longer
rejected by SIMemoryLegalizer.
The tests only show differences in the generated ISA for volatile loads from
the constant addrspaces; so far we haven't waited directly after each such
volatile load, with this change we do. Arguably, these waits are unnecessary
since the accessed memory is not supposed to change, but, on the other hand,
one could argue that volatile accesses to memory that doesn't change are
pointless in the first place.
[mlir][ODS] Add partitions for attributes and types
Allow attributes and types to be grouped into named partitions, like
ops. Each def can set `partition` to a `Partition` record. Passing
`-attrdefs-partition=<name>` or `-typedefs-partition=<name>` to the
attrdef/typedef decls and defs generators then emits only the defs of
that partition. A large dialect can thus split its attributes and types
over several compilation units with narrower headers.
The implementation mirrors the approach used in op partitioning
with a `register<DialectClass>Attributes` function (or Types) is used to register every attribute (or type) of the dialect and dispatches to partition specific functions.
The `generated{Parser,Printer}` function saw the biggest change.
It is not generated as `generated<DialectClass>{Attribute,Type}{Parser,Printer}` which is a method with public linkage.
This method is also generated for non-partitioned dialects and the old `generated{Parser,Printer}` function soft-deprecated (but for now retained for migration purposes).
The additional testing, the test dialect's attributes and types are split into the
partitions `Core` and `Syntax`.
This roughly halves the compile time (15.1s -> 6.7s + 6.9s) and peak memory (721 MiB -> 385 and
376 MiB) of the largest test dialect attribute compilation unit.
[2 lines not shown]
[mlir][ODS] Generate hooks that register the attributes and types of a dialect
Dialects registered their generated attributes and types by expanding
`GET_ATTRDEF_LIST` (or `GET_TYPEDEF_LIST`) into the template arguments
of `addAttributes` (or `addTypes`).
This requires each and every type and attribute and their storage classes' to be defined at the callsite and is generally boilerplate that exists in most dialects.
This PR introduces a single registration hook that is generated by ODS and should be called from dialects' `initialize` method instead. The implementation of the hook now performs the registration.
The motivation and further advantage of this approach is that we can then also change the implementation of the registration method in ODS while keeping API compatibility. This is required for partitioning of attributes and types e.g. (https://github.com/llvm/llvm-project/pull/241935).
Docs have been updated to advise users to use the new registration method. However, no upstream dialect beyond the test dialect has been switched nor is the old method of registration planned to be deprecated as it is still useful in some contexts (e.g., extendible dialects or C++ defined types and attributes).
Co-authored-by: Claude <noreply at anthropic.com>
[mlir][ODS] Let the generated dispatch parsers use an already parsed mnemonic (#243474)
The generated `generatedAttributeParser` and `generatedTypeParser`
always parsed the mnemonic themselves. A dialect whose attributes or
types are generated into several files therefore could not try the
dispatch functions of each file in turn, since the first one already
consumed the token.
The fix is just to pass `*mnemonic` on to the `KeywordSwitch`, which
only parses the mnemonic if it is empty. All in-tree callers already
pass an empty mnemonic.
Split out of https://github.com/llvm/llvm-project/pull/241935
[VPlan] Rework usesFirstPartOnly (#237986)
The recursive first-part reasoning in VPInstruction is dead, and this
allows us to make the more general observation that usesFirstPartOnly is
a misnomer: whether or not the first part of a recipe is used never
depends on the recipe itself, and is entirely determined by whether the
user is statically determined to be a first-part user. Accordingly,
strip the redundant argument. As part of the rework, make the sole
onlyFirstPartUsed call more principled. The end result is a technically
correct change of ResumeForEpilogue being cloned per-part, as evidenced
in VPlan printing.
Assisted-by: llm, for testing