[SLP]Vectorize single-user instructions as the last-attempt seeds
Instructions with the single user cost one extract per lane, so they are
vectorized after all other roots in the function are exhausted, grouped by
the key/subkey pairs. Loads, addresses, compares and the operations, folded
away or contracted into the scalar FMA, are excluded. The rejected bundles
and the members of the priced minimal nodes are not retried, unless the
tree was dropped by the repacking overhead rather than by the members.
Reviewers: hiraditya, RKSimon, bababuck
Pull Request: https://github.com/llvm/llvm-project/pull/212579
[lldb][Python] Inline `lldb_iter` for better type inference (#214000)
Currently, the `lldb_iter` helper is used for providing `__iter__` in
the Python bindings:
```python
def lldb_iter(obj, getsize, getelem):
"""A generator adaptor to support iteration for lldb container objects."""
size = getattr(obj, getsize)
elem = getattr(obj, getelem)
for i in range(size()):
yield elem(i)
```
A type checker or LSP can't see through this function. Currently, that's
no problem, because it doesn't know the return type of any Swig wrapper,
but when we add type annotations (hopefully with Swig 4.5 in #213463),
`__iter__` remains untyped. So iterating through the wrappers won't show
the correct type.
As the functionality is fairly simple, it's easier to inline it. That's
what this PR does. Then a type checker can infer the return type.
[CostModel][X86] getArithmeticReductionCost - ensure we test the vXi1 reductions types before legalisation (#211043)
Pre-AVX512 these will be legalized to wider vector types and might match
against other reductions tables.
Noticed while working on improving logic reductions, but hit a case
with/without popcnt for bool sum reduction patterns - I've added a AVX2
test pass to check the (corrected) costs are still working
[NFC][CIR] Propagate SymbolTables better (#213972)
This came up during self-build, we are spending a lot of time in some
cases looking up using the global symbol table, which does no caching.
Previously we'd propagated this in a few places, but this patch removes
all uses of SymbolTable::lookup and adds the cache everywhere.
This involved changing the tablegen to include it in each of our
rewriters, plus the CirAttr lowering everywhere.
The only thing we have to take care of is to make sure we invalidate the
cache/update the cache whenever we add something with a name (see
createLLVMFuncOpIfNotExist).
This is NFC, as it isn't observable, other than being a build time
improvement.
[RISCV] Fix Xqci Fusions with Frame Indexes (#213815)
Pre-RA, the ADDI can contain a frame index rather than a register, which
causes `getReg()` to assert. These were missing the `CheckIsRegOperand`
that most other fusions have.
[CIR] Lower variadic calls in CallConvLowering for x86_64 (#213315)
CallConvLowering classified each function once from its declared
signature and reused that classification at every call site. An argument
passed through an ellipsis has no entry in the callee's parameter list,
so on x86_64 an ellipsis argument that needed an extension attribute, a
register coercion, or a byval slot was emitted unchanged whenever the
callee's declared parameters happened to need no rewrite, and reported
NYI when they did.
An ellipsis argument competes for the same registers as a declared one,
so the same two-eightbyte record goes in a register pair early in the
list and byval once the integer registers are gone. Variadic call sites
under the x86_64 driver are now classified from the call's own operand
types, and the declared parameter count reaches
`llvm::abi::FunctionInfo::create` as its `NumRequired` argument, which
is what lets the classifier tell a named argument from one passed
through the ellipsis. Today that flag only decides whether a large
vector goes in a register, and the CIR type bridge admits no vector
[25 lines not shown]
[InstCombine]Fold fcmp+select to min/max if its zero sign is missing
Look through phis, chained selects and the loop back edge to the
select itself and fold if no use can observe the sign of zero of the
result. This restores the fold for loop-carried and unrolled running
min/max values (fcsel -> fminnm on AArch64) lost to the signed zero
handling fix in matchSelectPattern (#210077).
Reviewers: nikic, dtcxzyw
Pull Request: https://github.com/llvm/llvm-project/pull/213133
[OpenMP] Simplify generic microtask dispatch (#214004)
Replace the generic microtask dispatcher's handwritten function-pointer
types and calls with a variadic-template helper and a macro for each
supported argument count.
The dispatcher still casts each microtask to the exact fixed-arity
signature required by platforms such as WebAssembly. This is intended as
a refactor only: the existing limit of 15 microtask arguments and the
diagnostic for larger argument counts remain unchanged.
This reduces the repetitive code and makes future changes to the
supported argument range easier to review.
Split out from #211071
[CostModel][AArch64] Add initial costs for `masked.compressstore` (#213712)
This adds an initial cost model for `masked.compressstore`. The tests
are based on `masked_expand_load.ll`, which covers all configurations
for the `expand`/`compact` instructions.
Note: Right now, we only report valid costs for `masked.compressstore`
operations that can be lowered with SVE1 (as that's all we handle ISEL
for at the moment).
[LoopPeel] Peel last iteration to enable load widening
In loops that contain multiple consecutive small loads (e.g., 3 bytes
loading i8's), peeling the last iteration makes it safe to read beyond
the accessed region, enabling the use of a wider load (e.g., b32) for
all other N-1 iterations.
Patterns such as:
```
%a = load i8, ptr %p
%b = load i8, ptr %p+1
%c = load i8, ptr %p+2
...
%p.next = getelementptr i8, ptr %p, 3
```
Can be transformed to:
```
%wide = load b32, ptr %p ; Read 4 bytes
[19 lines not shown]
[DirectX] Prevent `dxil-resource-access` from inserting a resource access in-between phi nodes (#211343)
The pass can incorrectly place a load/store within the phi nodes at top
of the basic block: https://godbolt.org/z/x5Ec4GWGT
This is resolved by updating `replaceHandleWithIndices` to adjust the
insertion point when the ptr comes from a phi node.
Resolves, in part, https://github.com/llvm/llvm-project/issues/211121
Assisted by: Claude Opus 4.8
[flang-rt] - Lightweight runtime assignment function (AssignSimple) for intrinsic-type assignments.
This PR introduces a lightweight assignment runtime path (`_FortranAAssignSimple`) for intrinsic-type arrays
with the goal of reducing compile-time overhead seen primarily in the form of severly increased time taken by LTO.
This PR includes only the changes to the runtime (flang-rt) and as such just with this PR compile-time improvements
will not be visible.
**Problem**
When compiling Fortran code with OpenMP GPU offload and `firstprivate(allocatable_array)`, LLVM's Attributor creates excessive abstract attributes analyzing complex runtime assignment machinery:
**Symptom:**
- **Test case:** 8-element allocatable integer array with `firstprivate` clause
- **Compile time:** 24.97s (vs 0.78s for `private` - **32x slower**)
- **Root cause:** LLVM Attributor analyzing complex Fortran runtime functions
**Why this happens:**
1. `firstprivate` requires copying arrays from host to device
[43 lines not shown]
[llvm-objcopy] Address reviewer feedback on AMDGPU test cleanups
- Remove unused -DMACHINE yaml2obj template variable in cross-arch-headers.test,
hardcode Machine: EM_NONE directly in the YAML instead
- Remove unused Flags: [[FLAGS=<none>]] template variable in cross-arch-headers.test
- Add comment in binary-output-target.test explaining that Arch: unknown is
intentional when converting from binary (e_flags=0, no EF_AMDGPU_MACH set)
[Clang][ARM] Fix immediate range for NEON widening left-shifts (#212459)
The ACLE specifies the C intrinsic 'vshll_n to have a valid immediate
range size of [0..eltsize] but it has a range of [0..((eltsize*2) - 1)].
Update the range check to match the specified behavior
---------
Co-authored-by: Lukacma <Marian.Lukac at arm.com>
[SPIR-V] Preserve float types through wide float shuffles and atan2 legalization (#213785)
fixes https://github.com/llvm/llvm-project/issues/213783
Propagate result types through G_SHUFFLE_VECTOR and G_FATAN2 during
post-legalizer type deduction. This prevents wide float vectors from
producing integer-typed OpCompositeExtract instructions.
Add generic float shuffle and wide atan2 regression coverage.
assisted by Copilot (GPT-5.6-Sol)
[X86] Don't assume the FPCLASS category mask is a literal (#213171)
`llvm-mc` asserts on a FPCLASS category mask given as a symbol:
```asm
vfpclassps $f0, %zmm1, %k1
```
```
Assertion failed: isImm() && "This is not an immediate", MCInst.h:85
```
`printFPCLASSComments` reads the last operand with `getImm()` without
checking it is one. The value is only known at link time, so there is no
category to describe; return early and print no comment.
Note this is a comment printer, so encoding is unaffected.
`--filetype=obj` already succeeds today and emits a placeholder
immediate plus an `R_X86_64_8` relocation, which is correct. The issues
describe this as producing a wrong encoding in release builds, which I
[7 lines not shown]
[flang] Add LLVM dialect dependency to VScaleAttr (#213931)
`VScaleAttr` creates an LLVM `VScaleRangeAttr`, but did not declare the
LLVM dialect as a pass dependency. This aborts when the input does not
otherwise load LLVM.
Declare the dependency and remove the unused FIR-typed argument from the
existing test. Parsing `!fir.ref` loads `FIROpsDialect`, which loads
`LLVMDialect` as a dependency and previously masked the missing pass
dependency.
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha at gmail.com>
[AArch64] Update cttz and ctlz cost model test. NFC (#213999)
This updates the tests to match ctpop, how we test other operations.
Some extra
type coverage and cssc is added.
[Clang] Restrict ClangScanDeps darwin-specific test not to run in cross-compile (#213884)
The test added in 316a29603228c5d5000e0ddf8dfba2a494ac7ee9 fails when
run on MacOS but targeting Linux as a cross compiler.