AMDGPU: Fix double interval removal in SIOptimizeExecMaskingPreRA (#242790)
An exec copy folded after its use was erased from an s_endpgm block
had its interval removed twice. Fixes an assert after 6a483810f0da.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
BPF: Fix removing the blocks after the start of an unwind
BPFUnwindLower erased each dead block as soon as it unlinked it, so a
dead block that was a successor of a later one was used after being
freed. It also kept an address-taken block but not the blocks it
branches to, leaving a branch to an erased block.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Remove unused functions (NFC) (#242850)
AMDGPURegisterBankInfo::splitBufferOffsets: The last caller was removed
on November 14, 2021 in commit a84a401f7e73b0fca629858d94205a8d208f41a2.
This patch also removes static getBaseWithConstantOffset as
splitBufferOffsets is the only caller.
R600TargetLowering::getStackAddress: The last callers were removed on
January 6, 2017 in commit 06200bd7bcee74d6268d4a499f45eaa9a511fc06.
SIRegisterInfo::getCompatibleSubRegClass: The last caller was removed
on September 11, 2026 in commit
0bf534a7b76c7623edb7785cd8b21d89ec63e5d9.
Assisted-by: Antigravity
[ConstantFolding] Fold vector `bitinsert` and `bitextract` (#242812)
#229115 added constant folding for scalar `bitinsert` and `bitextract`.
This extends it to vectors by folding each element with the scalar fold.
- An element with an out-of-range or `poison` offset becomes `poison`.
- If an element can't be folded, the vector isn't folded either.
```llvm
%a = bitextract <2 x i8>, <2 x b32> <b32 305419896, b32 305419896>, <2 x i32> <i32 0, i32 8> ; <i8 120, i8 86>
%b = bitextract <3 x i8>, <3 x b32> splat (b32 305419896), <3 x i32> <i32 8, i32 32, i32 poison> ; <i8 86, i8 poison, i8 poison>
%c = bitinsert <vscale x 4 x b32> zeroinitializer, <vscale x 4 x i8> splat (i8 1), <vscale x 4 x i32> splat (i32 8) ; splat (b32 256)
```
[lldb][FreeBSD] Fix file header and header guard (#242686)
5e5b799853af (#180624) changed renamed
`NativeRegisterContextFreeBSD_x86_64.h` to
`NativeRegisterContextFreeBSD_x86.h`, but the file header and header
guard remained the same. Match the new filename and file header/header
guard.
Fixes: 5e5b799853af (#180624)
IR: Check inline compatibility on the function attribute sets
hasCompatibleFnAttrs queried each attribute on the caller and callee
through which needs to find the function attributes in the
AttributeList. Instead pass the AttributeSet once and use them for the
inline rules, which only look at function attributes.
callgrind instructions, opt -O3: SPASS cnf.bc -0.20%, sqlite3 -0.12%,
kimwitu++ k.bc -0.11%. CTMark instructions:u: O3 -0.04%, ThinLTO -0.04%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RISCV][GISel] Correctly legalize bitreverse for odd bitwidths (#241773)
RISC-V incorrectly legalizes/lowers bitreverse of odd bitwidths. This,
e.g., breaks leela benchmark from SPECcpu2017 (bitreverse of i20). The
legalizer helper in
https://github.com/llvm/llvm-project/blob/d5311d181267086e337e4dcf44630494f365140f/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp#L10498
only works for multiples of 8 bit; however, the subsequently invoked
legalizer of bswap only works properly on multiples of 16 bit. It would
be sufficient to widen the scalar to the next multiple of 16 (according
to my digging) but widening to next power of 2 seems safer with barely
any differences (8 and less is fine anyways as handled by a different
path).
[InstCombine] Relax pointer operand type check in foldCmpLoadFromIndexedGlobal (#242819)
This simplifies code and allows handling `GetElementPtrConstantExpr`.
DAG: Allow narrowing sint_to_fp source to the sext source type (#242783)
Same as 241c94e3919e for uint_to_fp. The narrowing fold skipped
sint_to_fp (sext x) when the narrow type matched x, so sitofp (sext i32
to i64) was expanded as a 64-bit conversion on AMDGPU.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
CSKY: Use LastSubtargetCache in getSubtargetImpl
Migrate to the new common pattern for targets to cache the last
result.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[lld] Don't reset LLVM options before parsing -mllvm (#242717)
https://reviews.llvm.org/D70378 added cl::ResetAllOptionOccurrences so
that a second in-process link would not fail with "may only occur zero
or one times!" on a repeated -mllvm option. That error was removed in
https://reviews.llvm.org/D120455
Remove the reset:
* Library options are unaffected: they are parsed into a fresh
`LibraryOptionsContext` for
each link
* In-tree cl::opt variables are no longer reset. A link without -mllvm
will see the previous link with -mllvm specified value. This is
acceptable. Most high-profile options have been ported.
* cl::opt defined by a program that links in lld will no longer be
reset. This fixes a regression from https://reviews.llvm.org/D70378
Xtensa: Use LastSubtargetCache in getSubtargetImpl
Migrate to the new common target pattern.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Bitstream: Move the slow path of Read out of line (#242772)
SimpleBitstreamCursor::Read was too large to inline into its
callers. Separate out the slow error path.
CTMark instructions:u: ThinLTO -0.23% (kimwitu++ -0.72%)
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Revert "[ConstraintElim] A signed sum of operands with opposite signs cannot wrap" (#242741)
Reverts llvm/llvm-project#235159
It introduced a runaway recursion bug in long chains of adds via the
recursive chain: `decomposeImpl` -> `isKnownNoWrap` -> `isKnownNoWrap` -
> `getKnownSign` -> `doesHold` -> `getConstraintForSolving` ->
`getConstraint` -> `decompose` -> `decomposeImpl`.
https://github.com/llvm/llvm-project/pull/235159#issuecomment-6887062333
Sparc: Use LastSubtargetCache in getSubtargetImpl
Adopt new common pattern for targets to lookup subtargets.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[llvm-c] Point C API target machines at the C API library options (#242692)
LLVMParseCommandLineOptions parses library options into
cl::getCAPILibraryOptions() and replays them into T::Global, which
target machines, JITs, and disassemblers created through the LLVM and
MLIR C APIs read since their MCTargetOptions::LibraryOptions is null.
Point them at getCAPILibraryOptions() and remove the replay.
LLM-aided
[SCEV] Use the union of the constants as range of selects of constants. (#242706)
A select of two constants that is not modeled as min/max becomes a
SCEVUnknown. Use union of constants as result range.
This improves precision in a number of cases in practice (218 files
changed): https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/2043
Only constant operands are handled; using the ranges of arbitrary
operands, via SCEV or computeConstantRange, is more costly and most
improvements seen in practice seem to come from selects of constants.
PR: https://github.com/llvm/llvm-project/pull/242706
DAG: Allow narrowing sint_to_fp source to the sext source type
Same as 241c94e3919e for uint_to_fp. The narrowing fold skipped
sint_to_fp (sext x) when the narrow type matched x, so sitofp (sext i32
to i64) was expanded as a 64-bit conversion on AMDGPU.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AMDGPU: Add more sitofp of sext from i32 tests (#242782)
These currently get the full i64 conversion expansion.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Mips: Use LastSubtargetCache in getSubtargetImpl (#242775)
Migrate to use the new common infrastructure and pattern which caches
based on the last used subtarget.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>