[SLP]Model or-reduction of masked shifted lanes as a bitfield pack
An or reduction of and(shl(x, s), m) lanes that each cover a disjoint
contiguous byte field of the result is a repacking of the per-lane field
contents, not a shift and reduce. Prove the fields disjoint from the
per-lane possibly-set bits (a saturating numeric upper bound combined with
known bits), then emit the pack as a trunc, an optional per-lane lshr, a
byte shuffle and a bitcast. A plain byte reversal becomes a bswap, an
identity byte order needs no shuffle, and byte-zext lanes compact for free.
Fixes #175446
Assisted-by: Cursor
Reviewers: bababuck
Pull Request: https://github.com/llvm/llvm-project/pull/219731
[RISCV] Account for VL toggle cost when splitting VP memory intrinsics (#223992)
Not an alternative to #222836 since this doesn't handle all cases, but
something we should do anyway in the TTI to be accurate.
For vp.load/vp.gather/vp.strided.load and their store counterparts, when
they're split they introduce extra vl toggles which involve computation
on the evl, e.g.
vsetvli a2, zero, e8, mf4, ta, ma
vmv1r.v v8, v0
csrr a2, vlenb
srli a3, a2, 3
vslidedown.vx v0, v0, a3
sub a3, a1, a2
sltu a4, a1, a3
addi a4, a4, -1
slli a5, a2, 3
and a3, a4, a3
[12 lines not shown]
[clang][bytecode] Add a function frame allocator (#220229)
Add a function frame allocator we share across evaluations.
For code like
```c++
consteval int foo() {
int a = 0;
for (int i = 0; i != 10; ++i)
inc(a);
return a;
}
```
We previously `new[]`-ed a frame for every call of `inc()`, and
`delete[]`d the memory again directly after, resulting in lots of small
(in this case) allocations.
Add a `FrameAllocator` class that handles frames like a LIFO stack and
allocates memory in 4kb chunks. If a newly created frame fits into an
[39 lines not shown]
[AArch64] Use SVE for load-extend-broadcast (#221689)
On certain cores, it is faster to use SVE ld1r instructions to load,
extend and broadcast an integer value to a vector in all cases other
than 64bit vectors where no type promotion occurs.
To acheive this, introduce a tuning option, `PreferSVEVectors` for use
when combining DUP instructions to create a Splat Vector to the scalable
alternative, and then use the already implemented scheduling model
patterns for splat vectors to end up generate the ld1r instruction.
If used in a loop, the predicate will be hoisted outside of the loop.
Fix llvm bdce debug salvage (#220900)
BDCE simplifies constant-mask `and`, `or`, and `xor` instructions when
the changed bits are not demanded by program uses. It can similarly
replace a `sext` with a `zext` when none of the sign bits are demanded.
Both transformations used ordinary RAUW, which also redirected direct
debug uses to values with different meanings.
Replace only non-metadata uses when applying these optimizations. This
leaves direct debug users for BDCE's existing reverse-order salvage
pass, which reconstructs supported operations in a `DIExpression` and
makes unsupported locations unavailable.
Add regression tests covering salvage of `and`, `or`, and `xor`, the
unavailable fallback for an unrepresentable wide constant, and
preservation of signed-extension semantics when program uses receive a
`zext`.
Fixes #218890
Fixes #46640
clang-linker-wrapper: Set the host DataLayout on the offload wrapper module
The offload wrapper module was created with only a target triple, and the
datalayout wasn't set until later, where it was copied from the TargetMachine,
after the wrapping code already ran.
The wrapping code did query the datalayout for the pointer size, so this was
broken for host and devices with different pointer sizes.
queries the DataLayout (e.g. the size_t / intptr type via getSizeTTy), so on a
host whose pointer size differs from the default layout (e.g. a 32-bit host) it
used the wrong integer width for image offsets.
This removes a use of TargetMachine::createDataLayout, which I am trying to
remove.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[OpenMP][DeviceRTL] Implement __kmpc_error for the error directive (#220702)
### Description
[OpenMP][DeviceRTL] Implement __kmpc_error for the error directive
### Notes
Part of #204240
Assisted-by: Github Copilot
[Clang] Fix deduction from constant TP of reference type. (#223645)
We were not implementing https://eel.is/c++draft/temp.deduct.type#13
properly.
Fixes #40328
Assisted-By: Opus 5
clang-linker-wrapper: Set the host DataLayout on the offload wrapper module
The offload wrapper module was created with only a target triple, and the
datalayout wasn't set until later, where it was copied from the TargetMachine,
after the wrapping code already ran.
The wrapping code did query the datalayout for the pointer size, so this was
broken for host and devices with different pointer sizes.
queries the DataLayout (e.g. the size_t / intptr type via getSizeTTy), so on a
host whose pointer size differs from the default layout (e.g. a 32-bit host) it
used the wrong integer width for image offsets.
This removes a use of TargetMachine::createDataLayout, which I am trying to
remove.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>