[AMDGPU][GlobalISel] Legalize G_MERGE_VALUES/G_UNMERGE_VALUES wider than max scalar
Treat a merge/unmerge whose combined type is wider than the largest
scalar as legal when each piece is already a legal register type.
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU] Assume nonzero EXEC at kernel entry for VA_VDST
Waves are launched with at least one active lane, so in a kernel EXEC
can only become zero at an EXEC write that may produce zero. Until such
a write, VALUs after an always-issued VALU are issued as well and may
credit its accesses as VA_VDST successors.
Track this per bracket. It starts set in entry functions, is cleared by
EXEC writes that may produce zero, and merges by intersection. Blocks of
an entry function propagate their state even with no pending events, so
a cleared fact reaches every merge.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU][NFC] Precommit tests for VA_VDST in kernels with nonzero EXEC
Record current waitcnt behavior for always-issued VALUs in kernels,
with and without EXEC writes before them.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SDAG] Simplify expandVECTOR_COMPRESS (#246657)
Simplifies expandVECTOR_COMPRESS to select between the load and the
passthrough at the end (rather than storing the passthrough first). This
seems to result in more compact code on AArch64/X86.
[SandboxVec][LoadStoreVec] Vectorize store chains whose loads have external uses
Loads that feed a store chain used to block vectorization whenever they
had more than one use. The store chain can now be vectorized even if the
loads have external uses. Once the scalar stores are erased, each
original load is rebuilt from the lanes it occupies in the new vector
load, and reinterpreted back to its original type if needed.
The legality check, canUnpack(), runs before any IR is created, so a load
whose lanes cannot be reinterpreted (for example, a non-integral pointer)
rejects the whole chain instead of leaving a partially rewritten block.
The unpacking itself is done by unpackIfNeeded() after the scalar stores
have been removed.
Update the store_seeds.ll and mixed_types.ll checks to match the new
output.
Co-authored-by: Cursor <cursoragent at cursor.com>
[CodeGenPrepare] Sink GEPs of gathers/scatters into the access block (#242746)
[CodeGenPrepare] Sink GEPs of gathers/scatters into the access block
SelectionDAGBuilder::getUniformBase only looks through a GEP defined in
the same block as the gather/scatter, since SelectionDAG is built one
block at a time. optimizeGatherScatterInst canonicalized such GEPs into
the "scalar base + vector index" form, but bailed out if the GEP was in
another block, with a FIXME to sink it instead.
This depends on https://github.com/llvm/llvm-project/pull/242745 where
the tests are precommitted.
This is common after LICM hoists a loop-invariant vector GEP out of a
loop, or after GVN shares a GEP between accesses to different fields of
a
vector of structs. The address is then materialized as a vector of
pointers in the defining block, kept live across the loop, and the
gathers/scatters use it with a zero base. E.g. on x86 each field gets a
vector of 64-bit pointers in the preheader, and AVX2 splits each gather
[41 lines not shown]
[MC][NFC] Replace MCAsmInfo::evaluateAsRelocatableImpl with func ptr (#246744)
Avoid a virtual function by using a function pointer for evaluating
specifier exprs. Saves ~400B of .data.rel.ro.
[Clang][AMDGPU] Remove R600 target support
Remove the r600 triple from the clang frontend, driver and CodeGen,
together with the `__R600__` macro and the `__builtin_r600_*` builtins.
AMDGPUTargetInfo now only handles amdgcn, so the R600 branches are gone.
```
$ clang --target=r600 -S test.cl
error: unknown target triple 'r600'
```
RFC: https://discourse.llvm.org/t/rfc-amdgpu-deprecating-and-removing-llvm-s-r600-terascale-backend/92840
[Clang][AMDGPU] Remove redundant isAMDGCN checks. NFC
After the r600 target removal, AMDGPUTargetInfo is only created for
the amdgcn triple, so every `isAMDGCN()` check in it is always true.
Drop those checks and the helpers that only wrapped them.
```
if (hasFMAF())
Builder.defineMacro("__HAS_FMAF__");
-->
Builder.defineMacro("__HAS_FMAF__");
```
RFC: https://discourse.llvm.org/t/rfc-amdgpu-deprecating-and-removing-llvm-s-r600-terascale-backend/92840
[clang-diff] Switch to OptTable (#246766)
Parse the command line with OptTable instead of cl::opt, as part of
removing cl::opt from clang/. Help output uses the OptTable format, and
LLVM's global options (e.g. -debug-only, --version) are no longer
accepted.
LLM-aided
[docs] Document signature of builtin functions more consistently (#246637)
This greatly increases the consistency in how the signature of builtin
functions is documented. Historically, only some of the intrinsics had a
proper pseudo-C++ declaration, only some provided a documented return
type, etc. Also, the formatting (west-pointer vs. east-pointer) was
inconsistent, and some declarations used `type` to express generics
while others use `T`.
This patch also fixes some more severe documentation issues:
- `__builtin_unpredictable` was documented to operate on `long long`,
but actually operates on `long`.
- `__builtin_bitreverseg` is undocumented.
---------
Co-authored-by: Timm Baeder <tbaeder at redhat.com>
[docs] Fix incomplete list of `constexpr` elementwise intrinsics (#246615)
The current list is missing several intrinsics that can be used in
constant expressions, such as `__builtin_elementwise_clmul`.
[SPARC] Emit relocations for symbolic immediates of sethi, unimp, Tcc, movr and movcc (#245946)
The immediate operands of sethi, unimp, Tcc, movr and movcc had no
encoder
method, so a symbolic operand reached getMachineOpValue() and hit
llvm_unreachable("Unhandled expression!"). This also happened for values
that are only known after encoding, such as a label difference or a
later
.set.
Give these operands encoder methods that emit a fixup for the field, as
GNU as does: R_SPARC_22 for sethi and unimp, R_SPARC_10 for movr and
R_SPARC_11 for movcc. GNU as uses R_SPARC_13 for a trap number, but on
V9
bits 12-11 of that field are the condition code, so use R_SPARC_7, which
covers just the trap number.
Fold the simm5/simm13 encoders into the same helper.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Driver] Merge CSKY bare-metal toolchain into BareMetal (#240290)
CSKYToolChain is only used for csky targets that are not Linux;
csky-*-linux-* is already handled by the generic Linux toolchain.
Fold the bare-metal handling into the BareMetal toolchain, as was
done for RISCVToolChain, and remove CSKYToolChain.
- Route csky in the default switch to BareMetal and add csky with an
unknown OS to BareMetal::handlesTarget().
- Use the "cskyelf" linker emulation for non-Linux csky targets.
- With a GCC installation, use libgcc/libstdc++ and no unwind library,
do not warn about multilibs, and apply the selected multilib's OS
suffix to the GCC install and sysroot library paths when the
multilib set does not provide a file paths callback.
- Add sysroot/include and sysroot/sys-include, link crti.o/crtn.o and
-lnosys (or -lsemi with -msim) instead of -lgloss.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Sparc][MC] Make register names case-sensitive (#245945)
matchRegisterName lowercased the name before calling the generated
matchers, so "%G1", "%SP" and "%R14" were accepted, but the hand-written
checks such as "%xcc", "%gsr" and "%tick" were case-sensitive, so "%XCC"
and "%GSR" were rejected.
GNU as only accepts lowercase register names. Do the same and stop
lowercasing the name.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang][RISCV] Added RTEMS OS target info for RISC-V (#241839)
Use RTEMSTargetInfo for riscv32-*-rtems and riscv64-*-rtems triples,
this is already done for ARM, SPARC and other architectures.
It makes clang emit __rtems__ macro when triples are used.
Add RISC-V RTEMS triples to predefined-macros-no-warnings.c
Add rtems-init.c test checking macros for all RTEMS targets.
[lld][Hexagon] Set copyRel to R_HEX_COPY (#245243)
copyRel was never initialized for Hexagon, so non-PIE copy relocations
were emitted as R_HEX_NONE and the linux musl loader left the copied
data zeroed, e.g. BusyBox's stdout.
[clang] Fix crash on trailing comma in vectorize_width
With `#pragma clang loop vectorize_width(4, )`, the token after the comma
is the end marker for the loop hint. The parser diagnoses the missing
argument, then lexes past the marker. Error recovery consumes the
following loop and crashes at the end of the file.
```text
Stack dump:
1. <eof> parser at end of file
2. <stdin>:1:10: parsing function body 'f'
3. <stdin>:1:10: in compound statement ('{}')
```
Leave the end marker for the existing recovery path so parsing resumes
at the following loop. Clang now emits only the malformed hint error.
```text
<stdin>:2:40: error: vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')
[6 lines not shown]