[SelectionDAG] Convert soft-promoted f16 to wide integers without a libcall (#235259)
#230779 converts `f16` to the half-width integer type and extends it
when the result of `fp_to_[su]int` must be expanded, but only when `f16`
is legal. When `f16` is soft-promoted (e.g. RISC-V with F but without
Zfh, ARM with VFP but without fullfp16), the conversion still calls
`__fixsfti`, `__fixsfdi`, `__aeabi_f2lz` or their unsigned variants.
Take the same path when `f16` is soft-promoted and `f32` is legal; the
narrower conversion extends the operand to `f32`. The conversion keeps
`f16` as its source type, so that the second expansion of `i128` on
32-bit targets also takes this path. Targets without `f32` keep the
libcall.
Assisted-by: Claude Opus 5.5
[AArch64] Implement latency costs for interleaved loads (#236428)
This is done by moving the existing code for getting the latency of
plain loads out into a separate function and calling that.
[flang][MIF] Add lowering for EVENT_QUERY (#237317)
This PR adds lowering support for the `EVENT_QUERY` intrinsic. It is
lowered to a new `mif.event_query` operation, which is then converted to
the corresponding PRIF call.
---------
Co-authored-by: Dan Bonachea <dobonachea at lbl.gov>
[flang][MIF] Fix STAT= specifier handling in coarray allocation #231248 (#237327)
`ALLOCATE `of a coarray with `STAT=` did not handle the result of
`prif_allocate_coarray `correctly:
The result of the allocation was never checked if STAT is specified, so
the descriptor update the base_addr, the default initialization and
`prif_sync_all `ran even when the allocation failed.
Fixes #231248.
---------
Co-authored-by: Dan Bonachea <dobonachea at lbl.gov>
Co-authored-by: Eugene Epshteyn <eepshteyn at nvidia.com>
[LoongArch] Match BSTRINS when an OR operand is already a BSTRPICK
performANDCombine rewrites (and X, mask) into BSTRPICK, or into
(shl (BSTRPICK X, msb, lsb), lsb) for a shifted mask. The BSTRINS
patterns in performORCombine only match ISD::AND, so they miss an OR
whose AND operand was rewritten before the OR was combined. In the
default order this happens when the operand only becomes an AND after
the OR was combined, e.g. in an expanded funnel shift. With
-combiner-topological-sorting (#83422), which visits operands before
their users, it happens for any OR. The OR is then selected as separate
bstrpick, shift and or instructions.
Before matching, turn such operands back into the AND they came from,
and build the result from the original operands. The pattern conditions
are unchanged.
In the default order this shortens the funnel shift tests. In a sample
of real-world bitcode compiled for loongarch64, 7 functions get shorter
and none longer, e.g. a byte inserted into the top of an i64 and vXi1
[3 lines not shown]
[LoongArch] Add BSTRINS tests with an OR built from a funnel shift (NFC)
Expanding the funnel shift creates the OR first. Its operand only
becomes an AND, which performANDCombine turns into BSTRPICK, after the
OR has been combined, so no BSTRINS pattern matches when the OR is
combined again.
Assisted-by: Claude Code (Claude Opus 5.5)
[AArch64] Add __ARM_FEATURE_LSCP macro (#241957)
This patch adds macro for detecting presence of
FEAT_LSCP feature as proposed in
[ACLE](https://github.com/ARM-software/acle/pull/477)
[lldb][test] Report the launch error in test_breakpoint_one_shot (#243803)
`TestBreakpointHitCount.test_breakpoint_one_shot` on the
`lldb-cmake-sanitized` failed
```
ERROR: test_breakpoint_one_shot (TestBreakpointHitCount.BreakpointHitCountTestCase)
...
AttributeError: 'NoneType' object has no attribute 'IsValid'
```
`SBTarget::LaunchSimple` launch failed, but caller doesn't get the
error.
The fix is to replace it with `Launch`, and call `assertSuccess(error)`.
Assisted-by: Claude
[libc++][pstl] Add a serial implementation of std::copy_if (#241782)
This PR adds a serial implementation of `std::copy_if` to PSTL.
Within this patch it's added only to the serial backend, such that any
other backend can fall back to this implementation.
A real parallel implementation is intended to land within the statpart
backend later, which will be a purely additive change, it will not touch
the code in this PR.
Part of #99938.
[flang][OpenMP] Handle declarative METADIRECTIVES more carefully
Diagnose declarative METADIRECTIVEs with executable variants as errors.
A METADIRECTIVE is considered executable if it contains at least one
executable variant. Mixing declarative and executable variants is not
supported.
There are several things that can appear in either the specification part
or in the execution part in a Fortran program unit. METADIRECTIVEs are
one example, and there is already code that tries to canonicalize then,
i.e. move them into the execution part if they are considered executable
and are at the end of the specification part.
In fact, the entire tail of the specification part is moved into the
execution part if it could be considered executable.
Since OmpMetadirectiveDirective is an allowed member of a specification
part, the parser will preferentially insert METADIRECTIVEs into the
specification part even if they are executable according to the above
definition.
[7 lines not shown]
[SLP]Inverse trunc to i1 bit tests in select conditions
InstCombine folds select (icmp eq (and X, 1), 0), A, B to
select (trunc X to i1), B, A, which swaps the select operands of the
trunc lanes against the other eq bit tests. Emit these lanes as
and X, 1 == 0 with the swapped gathered operands, and price them as
the bit test compares.
Fixes #238902
Assisted-by: Cursor
Pull-request: https://github.com/llvm/llvm-project/pull/238984
Reviewers: RKSimon, bababuck
Reviewed-by: bababuck
[Offload][NFC] Avoid unnecessary string copies (#243794)
A few small changes suggested by a static code analysis tool to avoid
unnecessary std::string copies.
A summary of the changes and reason is here (AI-generated):
- Plugin::error / createOffloadError (Error&& overload) in
OffloadError.h and PluginInterface.h: take a StringRef context instead
of const char *. Callers holding a std::string no longer go through
c_str() and a second std::string construction.
- L0Device.cpp: pass the message std::string directly to Plugin::error
instead of Buffer.c_str().
- JIT.cpp: createTargetMachine takes the CPU name as StringRef instead
of std::string by value. It is never modified and is only forwarded to a
StringRef parameter.
- L0Program.h / L0Program.cpp: KernelsToModuleMap is a llvm::StringMap,
so kernel-name lookups no longer build a temporary std::string.
try_emplace keeps the same first-entry-wins behavior as emplace.
Assisted by Claude.
[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