[X86] Add VMTRUNC/VMTRUNCS/VMTRUNCUS upper elements handling
computeKnownBitsForTargetNode - the masked truncations zero the
elements above the truncated ones, like VTRUNC/VTRUNCS/VTRUNCUS.
isGuaranteedNotToBeUndefOrPoisonForTargetNode - these upper elements
are never undef/poison. #245048 adds the same handling for VTRUNC.
Assisted-by: Claude Code (Claude Opus 5.5)
[VPlan] Return nullopt for irregular types in getConstantStride (NFC). (#247643)
Instead of asserting that the access type is not irregular, return
std::nullopt from vputils::getConstantStride. Callers no longer need to
guard the call with hasIrregularType themselves.
[AArch64] Implement ACLE intrinsics for FPv2 SVE min/max instructions
ACLE PR: https://github.com/ARM-software/acle/pull/480
Implements the following intrinsics:
- svmaxmg / svminmg
- svmaxinm / svmininm
- svmaxmginm / svminmginm
Includes f16, f32, and f64 types, _m, _z, and _x predication and _n variants
AI assistance: Codex used for generating test cases
[mlir][x86] Lower F16 `contract` to FMA using AVX2 F16 packed ops and BF16 fallback. (#245914)
Extend the `VectorContractBF16ToFMA.cpp` pass to:
1. lower `F16` type `vector.contract` to `vector.fma` using `AVX2` F16
packed operations:
- `vbcstnesh2ps` - Broadcasts F16 into packed F32,
- `vcvtneeph2ps` - Convert packed F16 even-indexed elements into packed
F32,
- `vcvtneoph2ps ` - Convert packed F16 odd-indexed elements into packed
F32.
2. fallback case for `bf16` type (both avx2 and avx512).
[VPlan] Use vputils::getLoadStoreValueType in more places (NFC). (#247639)
Replace manual computations of the loaded/stored type from operands or
the underlying IR instruction with vputils::getLoadStoreValueType. Make
the helper take a const pointer, so it can be used from const methods.
[Clang] Add regression test for #161196 (#247438)
Add a regression test for #161196 (an undeduced variable template type
used in decltype)
The test file is renamed to undeduced-variable-template.cpp since it now
contains tests for three different issues.
Fixes #161196
[clang][Driver] Add the OpenACC offloading kind
Add the OpenACC offloading kind to the flang driver. -fopenacc with
--offload-targets= or --offload-arch= creates the offloading toolchain. OpenACC
will have no device compilation job. There is a single host compilation job,
which will also generate and embed the device image. The link then goes through
the offloading linker wrapper as usual. Initially, OpenACC will support only a
single offloading architecture, thus, an error is emitted if more are given.
Assisted-by: Claude Sonnet 5.5
[mlir] Handle lexical/dominance inversion in OperationEquivalence (#244180)
Operation equivalence used to traverse blocks in their lexical order,
i.e., the order in which they are stored in the region. This order is
not guaranteed to match the dominance order. Operation equivalence
therefore would not have marked dominating values from a lexically
following block as equivalent in the cache, and would incorrectly
consider them as not equivalent.
Traverse all blocks first to record equivalence between arguments and op
results first, then look at operands separately.
[llvm-cov] Look up expansion regions by FileID with binary search (#246474)
The following problem was encountered while computing coverage for the
LLVM codebase. `llvm-cov export` on an instrumented `opt` took ~20min
for a profile from the AMDGPU lit suite (~7k tests). After these changes
it took 10s. The output was byte identical in both instances.
`llvm-cov` repeatedly look up entries by key in a container that is
already sorted by that key. Each lookup is conceptually selecting a
contiguous subrange. The old code scanned the whole container every
time. The PR replaces that with a binary search over the subrange. The
containers are already sorted; the PR only introduces assertions to
validate it.
The logical changes are introduced in
`CoverageMapping::getCoverageForExpansion` (easier to start reading from
there). The linear scan is replaced by an equivalent binary search over
the subrange.
[8 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}
[43 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
[LV] Use local wrap flags to eliminate zext/sexts in compressed ptr SCEVs (#241846)
This allows vectorizing cases where the conditional induction is
narrower than the width of a pointer type.
This is fairly common if the conditional induction was declared as an
`int` and the trip-count of the loop is unknown.
[mlir] Handle lexical/dominance inversion in OperationEquivalence
Operation equivalence used to traverse blocks in their lexical order, i.e., the
order in which they are stored in the region. This order is not guaranteed to
match the dominance order. Operation equivalence therefore would not have
marked dominating values from a lexically following block as equivalent in the
cache, and would incorrectly consider them as not equivalent.
Traverse all blocks first to record equivalence between arguments and op
results first, then look at operands separately.
[AArch64] Sink expressions that can form DEC/INC Z instrucitons
Sinking of the whole "scaled vscale splat" chain is necessary for SDAG
to select it to DEC/INC instuctions. This can help reduce ZPR register
pressure. Previously, the splats had to stay live throughout the whole
loop, or loop nest.
Assisted-by: codex (test creation)
[CIR] Handle integers wider than 64 bits in the vector constant folders
`cir::IntAttr::getUInt()` and `getSInt()` assert when the value needs
more than 64 bits. The folders of `cir.vec.cmp`, `cir.vec.ternary` and
`cir.vec.shuffle.dynamic` read constant elements through them, so they
asserted on a vector of `__int128` with such an element. C++ reaches
all three at -O0. The verifier of `cir.vec.shuffle` read its indices the
same way and asserted while parsing an index wider than 64 bits.
They now work on the `APInt` values:
- `cir.vec.cmp` compares the elements at their full width.
- `cir.vec.ternary` tests whether the condition element is zero.
- `cir.vec.shuffle.dynamic` masks the index before narrowing it.
- The `cir.vec.shuffle` verifier recognizes the -1 index by all of its
bits being set and range-checks the other indices without narrowing
them.
Folds of integers up to 64 bits are unchanged.
[2 lines not shown]
[X86] combineSelect - only create VMTRUNC from a legal source type
The select(c, trunc(x), y) -> VMTRUNC fold for targets without BWI
(#201339) runs before type legalization. With AVX512VL and a 256-bit
preferred vector width, v16i32 and v8i64 are illegal, and the type
legalizer can't split the operand of the target node: "Should not
custom lower this!". Reachable from C with -mavx512f -mavx512vl
-mprefer-vector-width=256; real code such as libwebp's sharpyuv hits
it. The same fold also crashed with "use-soft-float", where no vector
type is legal.
Assisted-by: Claude Code (Claude Opus 5.5)
Revert "[ARM][NFC] Remove global state from ARMLatencyMutations (#246973)" (#247645)
This reverts commit a3139c6e269bfa03c89f6ab1091c5dc83313984a as it was
not an
NFC and caused performance regressions.
The MCInstrDesc from TII->get(MI) is apparently:
// The table is indexed backwards from the last entry.
return *(LastDesc - Opcode);
So markDPProducersConsumers was now reading completely the wrong
entries.
I plan to try to remove the global in a followup patch.
[AMDGPU] Fix gfx950 MFMA co-exec rows for XDL2x_8Pass, SMFMAC2x, DGEMM (#245293)
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
[7 lines not shown]
[DebugInfo][FLMD] Add MIR printing/parsing support for !!dbgLoc
Extending from the IR printing/parsing support, this adds !!dbgLoc parsing
to the MIR parser, and has the MIR printing passes access the conversion
layer via the ModuleSlotTracker. Just as with regular debug-location
attachments in MIR, we print the attachments in their expanded/in-line form
if the same attachment did not appear in the IR, because the IR module may
have already been printed, and thus we cannot add new metadata IDs to the
printed output - in this case, we cannot add to the SrcLocs or InlinedAts
storage arrays.
Note that we can meaningfully print the SrcLoc in-line, but not the
InlinedAt, since that has a unique identity - this is a case that is very
unlikely to be stimulated however, and (I believe) already exists as a
deficiency in current IR, so we accept its absence for now. If this were
to become a significant issue, then we could implement in-line InlinedCall
printing.
AI assistance was used to partially generate the test input in this patch;
all test comments/checks were hand-written.
[TBAA] Use SmallVector for type paths in getLeastCommonType (NFC) (#244115)
Since https://github.com/llvm/llvm-project/pull/235556, cycle detection
in getLeastCommonType is only an assert, so SmallSetVector is no longer
needed. Switch to SmallVector and check !is_contained(...) in the assert
instead.
CTMark instructions:u geomean (x86_64): O3 -0.11%, ThinLTO -0.14%.
[flang][Driver] Offload OpenACC with -fopenacc and an offload target
Add the OpenACC offloading kind to the driver. -fopenacc with
--offload-targets= or --offload-arch= creates the offloading toolchain of the
device. OpenACC has no device compilation job: there is a single host
compilation, which is going to generate the device image, and the link goes
through the offloading linker wrapper.
OpenACC supports a single offloading architecture, which is diagnosed if more
are given.
Assisted-by: Claude Sonnet 5.5