[InstCombine] Fold extraction of low integer bits from scalar FP
A scalar FP bitcast to an integer vector followed by extraction of its
least-significant element can use a scalar integer bitcast and truncation.
For example, extracting element zero of a float-to-<32 x i1> bitcast on a
little-endian target becomes a float-to-i32 bitcast followed by truncation
to i1. This avoids making vector legalization reconstruct an existing
scalar bit projection. A one-element vector needs only the scalar bitcast.
Extend foldBitcastExtElt for this case. Require the vector bitcast to have
one use, an integer result, and no shift after accounting for endianness.
A newly introduced source-width integer must be desirable under DataLayout
to avoid wide scalar intermediates that regress codegen. Preserve the
existing integer-source shift restrictions.
The fold reinterprets bits without FP arithmetic, preserves operand-use
count, and does not look through freeze. Update the baseline test checks.
Alive2 proof of the motivating little-endian float-to-i1 case, with poison
[2 lines not shown]
[InstCombine][NFC] Add tests for extracting integer bits from scalar FP
Add coverage for scalar FP-to-integer-vector bitcasts followed by constant
element extraction, including the float-to-<32 x i1> case. Capture existing
behavior for both endiannesses and different legal integer widths, with
one-element, multiple-use, variable-index, FP-result, poison, out-of-range,
and freeze cases.
Generate checks with the unmodified compiler. All eight RUN configurations
pass before adding the scalar FP extraction fold.
[clang][Driver] Use the bare-metal toolchain for LoongArch (#223703)
Clang did not handle loongarch32-\*-none-elf and loongarch64-\*-none-elf
in the
bare-metal toolchain, so these targets fell back to the generic ELF
toolchain,
which links by running gcc. Any -fuse-ld or --ld-path option is
forwarded to
gcc, and linking fails when there is no gcc. On a host whose gcc does
not target
LoongArch, which is the usual case when cross compiling, gcc drives the
linker
for the host, and the link fails with errors such as "a.o is
incompatible with
elf_x86_64". The generic ELF toolchain also searches /usr/local/include
and
/usr/include of the host.
The other bare-metal targets, Arm, AArch64, RISC-V, PowerPC, and x86
[12 lines not shown]
[M68k][NetBSD] Fix alignments for NetBSD/m68k. (#207602)
Linux/m68k uses the ABI from Sun Microsystems for a.out on m68k, which
aligns ints/objects/pointers/stack on 16-bit boundaries.
NetBSD/m68k on the other hand uses the ABI from SVR4 for m68k, which
aligns ints/objects/pointers/stack on 32-bit boundaries.
This is a follow-up of
https://github.com/M680x0/issues/issues/13
[CIR] Match the parameter spill shape instead of asserting it
Return null from findParamSpill when a non-byval indirect parameter's
only use is not a store into an alloca it names directly, instead of
asserting that shape. Both callers already handled a null result, so
an unmatched parameter now reaches the diagnostic the forwarding call
already has for an operand that does not name the caller's storage.
Assisted-by: Cursor / claude-opus-5
[AMDGPU] Add LDS encoding granularity to TargetParser
Model LDS encoding granularity with dedicated features and expose the
byte-valued getLDSEncodingGranule query for GPUKind and subarch. Keep
encoding independent of the hardware allocation granularity used for
occupancy; GFX10.3, GFX11 and GFX12.0 encode in 512-byte units while
allocating 1024-byte blocks.
Migrate program resource register and PAL metadata encoding to the new
query and remove getLdsDwGranularity from AMDGPUBaseInfo. gfx9-4-generic
uses gfx950's 1280-byte encoding granule independently of LDS capacity.
Test encoding queries, feature membership, generic-target validation and
encoded LDS sizes, including the GFX10.3 allocation/encoding distinction.
Change-Id: I9d3c2c041605e9a45fa8fbda09fc3460a74953ea
[AMDGPU] Return zero LDS encoding granularity for dummy targets
Remove the redundant early return and assertion from getLDSEncodingGranule. Return zero when the target has no encoding granularity feature, and document and test the result for unknown and legacy generic targets.
Keep the existing 256-byte default in the assembly printer so compiling without a GPU still produces valid LDS sizes. Test default-target Mesa and PAL encodings and HSA metadata.
Change-Id: Ia0c69a0d7ce2858b31ee64100d37ae34bba6c42c
[AMDGPU] Add partial unroll threshold function attribute (#223291)
This change adds an `amdgpu-partial-unroll-threshold` function attribute
for controlling
`TargetTransformInfo::UnrollingPreferences::PartialThreshold` on a
per-function basis.
The existing `amdgpu-unroll-threshold` function attribute initializes
`UP.Threshold`, which is used for decisions about full
unrolling. However, there is currently no corresponding AMDGPU function
attribute for configuring `UP.PartialThreshold`
independently. As a result, clients of the AMDGPU backend cannot provide
an independent per-function cost threshold for partial and runtime
unrolling.
When present, the new attribute sets the base value of
`UP.PartialThreshold` for loops in that function. This allows the cost
threshold for partial and runtime unrolling to be configured
independently of the threshold used for full unrolling. Functions that
[5 lines not shown]
[VPlan] Add VPBlockUtils::replaceSuccessor helper (NFC). (#224970)
Add a helper to redirect a single edge, keeping the successor order and
updating the predecessor links of both the old and new successor. Use it
in insertBlockBefore.
[AMDGPU] Fold fpround of fadd and fsub into v_mad/fma_mixlo and mixhi
MadFmaMixFP32Pats turns (fadd x, y) into (fma x, 1.0, y) and (fsub x, y)
into (fma (-y), 1.0, x) so the mix instructions absorb the operation along
with the f16 or bf16 source modifiers. MadFmaMixFP16Pats and
MadFmaMixFP16Pats_t16 only did this for fmul, so a rounded result still
needed a separate convert for a rounding the mix instructions perform
themselves.
Unlike the f32 patterns these do not require an operand to be an fpextend
of an f16, since an fpround on the result always removes the convert. The
rewrite is exact because the mix instructions round the f32 result again
when they write the 16-bit destination, so it stays f32_to_f16(fma(x, 1.0,
y)).
Assisted-by: Claude Code Opus 5
[AMDGPU] Require flushed FP16 denormals for the mad-mix f16 results
v_mad_mixlo_f16 and v_mad_mixhi_f16 are the unfused gfx900 forms and flush
16-bit denormals, so a denormal half result is written as zero even when the
FP16 mode asks for it to be kept, while the patterns only required the FP32
mode to flush and that is the one a HIP compile turns off on its own.
Assisted-by: Claude Code Opus 5
[NFC][AMDGPU] Add tests for fpround of fadd and fsub feeding the mix instructions (#224909)
The f32 mix patterns already fold fadd and fsub into v_mad_mix_f32 and
v_fma_mix_f32, but the f16 and bf16 forms only fold fmul, so a half or
bfloat result still pays for a separate convert.
Also cover the denormal modes an f16 result depends on and an f16
source feeding an f16 or bf16 mix. The existing mad-mix-lo and
mad-mix-hi functions now flush denormals for every type rather than
for f32 alone.
Assisted-by: Claude Code Opus 5
[LoopInterchange] Avoid overflow in the memory-instruction ratio check (#214920)
populateDependencyMatrix bails out if MaxMemInstrRatio * NumInsts is
less than NumMemInstr * NumMemInstr. Both products are computed in
32-bit unsigned arithmetic and can wrap, e.g., with
-loop-interchange-max-mem-instr-ratio=2147483648 and 20 instructions the
left product wraps to 0 and the pass rejects an otherwise eligible nest.
Compute both products in uint64_t instead, which cannot overflow as all
three operands are 32 bits wide.
Assisted-by: Claude Opus 5, GPT-5.6 Sol, GPT-6 Astra, Claude Fable 5.1.
Co-authored-by: Matt P. Dziubinski <matt-p.dziubinski at hpe.com>
[SandboxVec][LoadStoreVec] Support constant vectors of mixed types
createConstantVector() previously packed the constant store operands
as-is, which only worked when every store had the same element type.
Take the lane type from VecUtils::getCombinedVectorTypeFor() instead and
reinterpret each constant's bits as that type, going through an integer
of matching width via ptrtoint/inttoptr/bitcast. Constants wider than a
lane (e.g. an i64 in an <N x i32>) are split across several lanes in
memory order. Bail out when a constant cannot be reinterpreted, such as
a non-integral pointer or a relocatable address that needs splitting.
Also flatten vector-typed ConstantPointerNull into per-lane nulls, and
bail out on the remaining vector constants such as poison rather than
packing them into the result.
Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>
[lldb] Implement the `__repr__` method for SBStringList. (#224134)
It was annoying to working with `SBStringList` from the lldb python
repl, because printing it out will produce something like.
`<lldb.SBStringList; proxy of <Swig Object of type 'lldb::SBStringList
*' at 0x10556a7b0> >`.
This also implicitly implements `str(SBStringList)`.
Extend the `__getitem__` behaviour to cover integer slices. Add test
cases.
[libc] Move File::close out of line to file.cpp (#224901)
Moved File::close from src/__support/File/file.h into
src/__support/File/file.cpp and removed #include
"src/__support/CPP/new.h" from file.h, matching Dir::close in
src/__support/File/dir.h.
src/__support/CPP/new.h renames global operator delete via __asm__ to
__llvm_libc_delete (which calls free) for the entire translation unit
without renaming operator new. Including new.h in file.h leaked this
replacement operator delete into unit test translation units that
include file.h, causing an AddressSanitizer alloc-dealloc-mismatch in
Test::createCallable during death tests.
Assisted-by: Automated tooling, human reviewed.
[LV] Add tests for early-exit loops with faulting loads (NFC). (#224762)
Pre-committing the tests for using @llvm.speculative.load intrinsic in
LoopVectorize.
[libc] Fix mlock, mlock2, and munlock signatures (#224905)
Updated libc/include/sys/mman.yaml so the first parameter of mlock,
mlock2, and munlock is const void * rather than void *.
Updated libc/src/sys/mman/mlock2.h and
libc/src/sys/mman/linux/mlock2.cpp so the flags parameter is unsigned
int rather than int.
Assisted-by: Automated tooling, human reviewed.
CodeGen: Move DataLayout computation to CodeGenTargetMachineImpl's ctor
Every target's TargetMachine constructor passed TT.computeDataLayout() as
the DL string argument to the base constructor, duplicating the same call
across all backends. Some backends just didn't bother passing in the ABI
name.
Co-Authored-By: Claude <noreply at anthropic.com> (Claude Opus 4.8)