LLVM/project 62e1f86 — mlir/docs PassManagement.md, mlir/lib/TableGen Pass.cpp

[mlir][tblgen] Add `cppNamespace` to passes (#247681)

The code generated by `-gen-pass-decls` has no notion of a namespace and
is placed wherever the generated file is included, which in practice is
always inside a namespace. The generator can therefore not emit anything
that has to live at global scope, such as includes or forward
declarations.

Add a `cppNamespace` field to `PassBase`, similar to the one of
dialects. Passes that set it place their generated code in that
namespace themselves, and the generated file must then be included at
global scope. The group registration is placed in the innermost
namespace enclosing the namespaces of all passes of the group, if any.
Passes without a namespace behave as before.

This makes namespace handling of passes also consistent with the rest
the of MLIR.

---------

Co-authored-by: Claude <noreply at anthropic.com>
DeltaFile
+170-0mlir/test/mlir-tblgen/pass-cpp-namespace.td
+34-32mlir/tools/mlir-tblgen/PassGen.cpp
+39-0mlir/docs/PassManagement.md
+28-9mlir/tools/mlir-tblgen/PassCAPIGen.cpp
+30-0mlir/lib/TableGen/Pass.cpp
+24-0mlir/unittests/TableGen/PassGenTest.cpp
+325-413 files not shown
+350-419 files

LLVM/project da6ebf1 — llvm/test/tools/llvm-strings encoding.test, llvm/tools/llvm-strings Opts.td llvm-strings.cpp

Apply review feedback
DeltaFile
+4-4llvm/test/tools/llvm-strings/encoding.test
+1-1llvm/tools/llvm-strings/Opts.td
+2-0llvm/tools/llvm-strings/llvm-strings.cpp
+7-53 files

LLVM/project c2bb81b — llvm/lib/Target/AMDGPU SIInsertWaitcnts.cpp, llvm/lib/Target/ARM ARMBranchTargets.cpp

[Target] Use new skipMetaInstructions{Forward,Backward} helpers (NFC) (#247158)

Replace all loops that obviously do nothing but skip meta instructions
with calls to the new helper functions from PR #230074.
DeltaFile
+6-11llvm/lib/Target/Sparc/LeonPasses.cpp
+4-6llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+2-4llvm/lib/Target/Sparc/DelaySlotFiller.cpp
+2-3llvm/lib/Target/X86/X86MCInstLower.cpp
+2-3llvm/lib/Target/X86/X86InsertX87Wait.cpp
+1-3llvm/lib/Target/ARM/ARMBranchTargets.cpp
+17-306 files

LLVM/project a8816d9 — llvm/lib/Transforms/InstCombine InstCombineAddSub.cpp, llvm/test/Transforms/InstCombine ctpop.ll

[InstCombine] Fold trunc(ctpop(A)) + trunc(ctpop(B)) -> trunc(ctpop(A) + ctpop(B))

This allows the combine added in #231321 to kick in and fold the motivating ctpop case in automotive-bitcount:

```c
static char bits[256] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};

int CDECL ntbl_bitcount(long int x)
{
      return
            bits[ (int) (x & 0x0000000FUL)       ] +
            bits[ (int)((x & 0x000000F0UL) >> 4) ] +
            bits[ (int)((x & 0x00000F00UL) >> 8) ] +
            bits[ (int)((x & 0x0000F000UL) >> 12)] +
            bits[ (int)((x & 0x000F0000UL) >> 16)] +
            bits[ (int)((x & 0x00F00000UL) >> 20)] +
            bits[ (int)((x & 0x0F000000UL) >> 24)] +
            bits[ (int)((x & 0xF0000000UL) >> 28)];
}
```
DeltaFile
+5-12llvm/test/Transforms/InstCombine/ctpop.ll
+6-0llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+11-122 files

LLVM/project 0ec4180 — llvm/test/Transforms/InstCombine ctpop.ll

Precommit tests
DeltaFile
+41-0llvm/test/Transforms/InstCombine/ctpop.ll
+41-01 files

LLVM/project a516dd2 — llvm/lib/Transforms/InstCombine InstCombineAddSub.cpp, llvm/test/Transforms/InstCombine ctpop.ll

[InstCombine] Fold ctpop(X >> C) + ctpop(X & M) -> ctpop(X & (M | (-1 << C)))

Following up from #231225, automotive-bitcount in llvm-test-suite and GCC use a "per-nibble" ctpop table lookup, where they split the operation up into smaller ctpop table lookups over chunks of the input:

```c
unsigned table_u32(unsigned x) {
  static const unsigned char ctpop[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
  return ctpop[x & 15] + ctpop[(x >> 4) & 15];
}
```

PR #231225 now converts the individual table lookups to ctpop intrinsics, so we're left with `ctpop(X & 0xf) + ctpop((X >> 4) & 0xf) + ctpop((X >> 8) & 0xf) + ...`. Now that `ctpop((X >> C) & M)` is canonicalized to `ctpop(X & (M << C))`, the existing `ctpop(A) + ctpop(B) -> ctpop(A | B)` fold for disjoint A and B combines most of these.

The one piece it can't handle is the top chunk of a full-width chain, which is a plain `ctpop(X >> C)` with no mask. This folds it with the lower bits directly.

This needs to come before the disjoint fold, which would otherwise combine e.g. `ctpop(X >> 12) + ctpop(X & 0xf00)` into `ctpop((X >> 12) | (X & 0xf00))`, which can't be folded any further.
DeltaFile
+6-22llvm/test/Transforms/InstCombine/ctpop.ll
+11-0llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+17-222 files

LLVM/project 3824017 — llvm/test/Transforms/InstCombine ctpop.ll

Precommit tests
DeltaFile
+145-0llvm/test/Transforms/InstCombine/ctpop.ll
+145-01 files

LLVM/project 66d3c88 — llvm/lib/Transforms/InstCombine InstCombineCalls.cpp, llvm/test/Transforms/InstCombine ctpop.ll

[InstCombine] Fold ctpop((X >> C) & M) -> ctpop(X & (M << C))

The position of the bits doesn't matter to ctpop so we can look through the shift. As suggested in https://github.com/llvm/llvm-project/pull/231321#discussion_r4358616796, this allows the existing ctpop(A) + ctpop(B) => ctpop(A | B) to kick in since it now knows there are no bits in common.
DeltaFile
+10-30llvm/test/Transforms/InstCombine/ctpop.ll
+8-0llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+18-302 files

LLVM/project 7ffeecf — llvm/lib/Transforms/InstCombine InstCombineVectorOps.cpp, llvm/test/Transforms/InstCombine vec_phi_extract.ll

[InstCombine] Fix scalarizePHI for phi inputs defined by a terminator (#247678)

scalarizePHI inserts the extract of each incoming value right after the
instruction that defines it. When that instruction is an `invoke` or a
`callbr`, there is nothing after it in its block, and InstCombine
asserts.

If it is the terminator of the phi's incoming block, its result is not
available anywhere in that block, so bail out. Otherwise insert the
extract at the start of the incoming block.

The issue reports the `callbr` case; `invoke` crashes the same way. The
new tests in vec_phi_extract.ll cover both, plus an invoke in an earlier
block, which now gets scalarized.

Fixes #247644

Assisted-by: Claude Code (Opus 5.5)
DeltaFile
+121-0llvm/test/Transforms/InstCombine/vec_phi_extract.ll
+8-1llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+129-12 files

LLVM/project 0542d39 — lldb/source/Plugins/Highlighter/TreeSitter TreeSitterHighlighter.h CMakeLists.txt

[lldb] Fix building with Tree-sitter on Linux (#231535)

I tried building with a locally built tree-sitter, manually passing
TreeSitter_<...>_DIR. To get that to work I had to fix two things.

1. The lldb libraries need to build with the tree-sitter header paths
included.
2. For whatever reason, clang 20 doesn't deem TSState to be default
constructible with "= default" but it does with "{}". It must be default
constructible for the later m_ts_state.emplace() calls to work.
DeltaFile
+4-0lldb/source/Plugins/Highlighter/TreeSitter/CMakeLists.txt
+1-1lldb/source/Plugins/Highlighter/TreeSitter/TreeSitterHighlighter.h
+5-12 files

LLVM/project ea1dfee — llvm/test/Transforms/InstCombine ctpop.ll

Precommit tests
DeltaFile
+169-0llvm/test/Transforms/InstCombine/ctpop.ll
+169-01 files

LLVM/project 83d5369 — libcxxabi/src private_typeinfo.h private_typeinfo.cpp

[libc++abi] Pass flags in a register
DeltaFile
+49-71libcxxabi/src/private_typeinfo.cpp
+51-45libcxxabi/src/private_typeinfo.h
+100-1162 files

LLVM/project 1916fc6 — llvm/lib/Transforms/InstCombine InstCombineInternal.h InstCombineNegator.cpp, llvm/test/Transforms/InstCombine sub-of-negatible.ll

[InstCombine] Cache Negator results per nsw flag (#247927)

Negator caches the negation of a value without recording whether it was
built with nsw. When the same value is negated twice, once with nsw and
once without, the second request gets the nsw version, which can be
poison where the original was not.

This keys the cache on the value and the nsw flag.

Fixes #235380

Assisted-by: Claude Code (Opus 5.5)
DeltaFile
+20-0llvm/test/Transforms/InstCombine/sub-of-negatible.ll
+4-3llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
+3-1llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+27-43 files

LLVM/project b2165a5 — mlir/lib/Dialect/Math/Transforms PolynomialApproximation.cpp, mlir/test/Dialect/Math polynomial-approximation.mlir

[mlir][math] Avoid infinity constant in erfc approximation (#239507)

The `erfc` polynomial approximation uses `+inf` as a bound when checking
whether `abs(x)` is finite. This changes `abs(x) < +inf` to `abs(x) <=
max_finite_f32`, which gives the same result for every FP32 input,
including NaNs and infinities.

Signed-off-by: anutosh491 <andersonbhat491 at gmail.com>
DeltaFile
+15-2mlir/test/Dialect/Math/polynomial-approximation.mlir
+6-4mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
+21-62 files

LLVM/project 20bdd12 — llvm/tools/llvm-strings llvm-strings.cpp

Move assert
DeltaFile
+4-3llvm/tools/llvm-strings/llvm-strings.cpp
+4-31 files

LLVM/project 1334b13 — llvm/test/Transforms/LoopVectorize hoist-loads.ll, llvm/test/Transforms/LoopVectorize/AArch64 scalable-call.ll

[LV][NFC] Introduce new lines between blocks of IR in some tests (#247723)
DeltaFile
+3-0llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll
+2-0llvm/test/Transforms/LoopVectorize/hoist-loads.ll
+2-0llvm/test/Transforms/LoopVectorize/RISCV/evl-invalid-cost-remark.ll
+1-0llvm/test/Transforms/LoopVectorize/X86/fneg-cost.ll
+8-04 files

LLVM/project ce25a5f — llvm/test/CodeGen/AArch64 sve-fixed-length-permute-zip-uzp-trn.ll sve-fixed-length-permute-rev.ll

[AArch64][CodeGen] Improved BUILD_VECTOR lowering for wider fixed-length SVE (#246021)

Non-constant BUILD_VECTORs lowered through fallback path materialize
stack spill and fill which can blow up for wider fixed-length SVE.

This patch lowers non-constant BUILD_VECTOR using 128-bit parts
and combining them together with SVE SPLICE, avoiding the fallback path.

Initial version of the patch was from Sander De Smalen.
DeltaFile
+688-788llvm/test/CodeGen/AArch64/sve-fixed-length-fp-extend-bf16.ll
+413-668llvm/test/CodeGen/AArch64/sve-interleaved-accesses.ll
+477-544llvm/test/CodeGen/AArch64/sve-fixed-length-masked-expandloads.ll
+184-0llvm/test/CodeGen/AArch64/sve-fixed-length-build-vector.ll
+6-42llvm/test/CodeGen/AArch64/sve-fixed-length-permute-rev.ll
+10-28llvm/test/CodeGen/AArch64/sve-fixed-length-permute-zip-uzp-trn.ll
+1,778-2,0702 files not shown
+1,807-2,0908 files

LLVM/project 4874054 — lldb/source/Plugins/ScriptInterpreter/Python PythonReadline.h PythonReadline.cpp

[lldb][OpenBSD] Enable the libedit readline compat module (#235228)

LLDB links libedit for its own line editing. The embedded Python
interpreter imports Python's readline extension module at startup, and
on OpenBSD that module links the GNU readline in base
(/usr/lib/libreadline.so). Both libraries then end up loaded in the
same process.

libedit implements a readline compatibility API, so the two libraries
define many of the same symbols. Because libedit is loaded first, its
definitions win, and GNU readline ends up bound to libedit's objects,
whose layout differs from what it expects. ld.so detects this for the
keymap tables and warns every time lldb starts:

```
  lldb:/usr/lib/libreadline.so.6.0: /usr/lib/libedit.so.7.0 : WARNING:
  symbol(emacs_meta_keymap) size mismatch, relink your program
  lldb:/usr/lib/libreadline.so.6.0: /usr/lib/libedit.so.7.0 : WARNING:
  symbol(emacs_standard_keymap) size mismatch, relink your program

    [29 lines not shown]
DeltaFile
+15-3lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
+1-1lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
+16-42 files

LLVM/project badee47 — llvm/test/Transforms/InferAddressSpaces/AMDGPU infer-address-space.ll

[NFC][AMDGPU] Eliminate stale FIXME to eliminate flat pointer use
DeltaFile
+0-1llvm/test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
+0-11 files

LLVM/project eed040f — llvm/lib/Transforms/InstCombine InstCombineSelect.cpp, llvm/test/Transforms/InstCombine select-to-cmp.ll

[InstCombine] Don't fold vector select with scalar cond into scmp/ucmp (#247947)

For scmp/ucmp the vector-ness of the inputs and the result must be the
same, so bail out if we have a select with scalar cond and vector values.

Fixes #241811.

Assisted-by: claude opus 5.5
DeltaFile
+68-0llvm/test/Transforms/InstCombine/select-to-cmp.ll
+5-0llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+73-02 files

LLVM/project b6d7b73 — llvm/lib/Target/RISCV RISCVInstrPredicates.td RISCVRegisterInfo.cpp, llvm/test/CodeGen/RISCV xqcilo-xqcilia-frame-index.ll xqcilo-xqcilia-sfb-frame-index.ll

[RISCV] Improve Xqcilo wide stack accesses beyond simm26 in PEI (#245876)

Predicated loads generated at peephole-opt as a result of folding
loads/stores from Xqcilo subextension can hold an immediate
within the range of simm26 however until now, in PEI,
in `eliminateFrameIndex`, the immediate is always restricted to
simm12 range and the leftover was materialised using
`PseudoAddUpperImm`. This PR fixes this issue by allowing the offsets
beyond simm12 range but within simm26 range to get encoded directly
in wide predicated load pseudos.

Additionally, this PR fixes the suboptimal split when the final offset
exceeds the simm26 range. Previously, the leftover part was always a
multiple of 2^26 which resulted in the generation of lui + add + 48-bit
lw/sw. However, if lui + add is generated then only a 12-bit offset is enough
to materialize the remaining part and therefore no need to have 48-bit lw/sw.

This PR fixes this issue by considering the below 4 instruction combos in
decreasing order of priority:

    [16 lines not shown]
DeltaFile
+1,449-0llvm/test/CodeGen/RISCV/xqcilo-xqcilia-sfb-frame-index.ll
+980-1llvm/test/CodeGen/RISCV/xqcilo-xqcilia-frame-index.ll
+71-2llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+15-4llvm/lib/Target/RISCV/RISCVInstrPredicates.td
+2,515-74 files

LLVM/project fc753e6 — llvm/lib/Target/Hexagon HexagonGlobalSchedulerV2.cpp, llvm/test/CodeGen/AMDGPU srem.ll load-global-i8.ll

Merge branch 'main' into llvm-strings-encoding
DeltaFile
+2,602-2,926llvm/test/CodeGen/X86/vector-compress.ll
+0-5,395llvm/test/CodeGen/AMDGPU/load-global-i8.ll
+0-5,274llvm/test/CodeGen/AMDGPU/srem.ll
+5,270-0llvm/lib/Target/Hexagon/HexagonGlobalSchedulerV2.cpp
+4,635-0llvm/test/CodeGen/ARM/constant-islands-convergence.mir
+4,302-0llvm/test/CodeGen/RISCV/GlobalISel/atomicrmw-max-min-umax-umin.ll
+16,809-13,5954,210 files not shown
+193,924-113,7984,216 files

LLVM/project 28522ed — llvm/lib/Target/AArch64 AArch64TargetTransformInfo.cpp, llvm/test/Transforms/InstCombine/AArch64 sve-intrinsic-and-xor.ll

fixup! [AArch64] Implement InstCombine for sve_and_u and sve_eor_u
DeltaFile
+9-18llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-and-xor.ll
+4-7llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+13-252 files

LLVM/project cabae28 — llvm/lib/CodeGen/SelectionDAG DAGCombiner.cpp

Ignore TypeScalarizeVector
DeltaFile
+5-0llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+5-01 files

LLVM/project 3656762 — llvm/lib/CodeGen/SelectionDAG DAGCombiner.cpp, llvm/test/CodeGen/AMDGPU extract_vector_dynelt_subbyte.ll

Add freeze check
DeltaFile
+24-1,069llvm/test/CodeGen/AMDGPU/extract_vector_dynelt_subbyte.ll
+9-2llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+33-1,0712 files

LLVM/project d689c3a — llvm/lib/CodeGen/SelectionDAG DAGCombiner.cpp, llvm/test/CodeGen/AMDGPU extract-load-i1.ll extract_vector_dynelt_subbyte.ll

[DAGCombiner] Scalarize variable index extracts from sub byte vectors

The type legalizer lowers a variable index extract from an illegal
vector with sub byte elements through the stack, storing one byte per
element. When the vector comes from a bitcast on a little endian
target, element $i$ occupies bits $[i \cdot w, (i+1) \cdot w)$ of the
source, so extract it with a shift of the integer word holding it.

```
t3: v64i1 = bitcast t2
t5: i1 = extract_vector_elt t3, t4
  -->
t6: i64 = bitcast t2
t7: i64 = srl t6, t4
t5: i1 = truncate t7
```

On gfx1200 this replaces 64 scratch stores and a scratch load with a
few VALU instructions. Byte sized elements, non bitcast sources and
non power of 2 sizes are left unchanged.
DeltaFile
+85-1,370llvm/test/CodeGen/AMDGPU/extract_vector_dynelt_subbyte.ll
+88-0llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+1-23llvm/test/CodeGen/AMDGPU/extract-load-i1.ll
+174-1,3933 files

LLVM/project 90dfaa7 — llvm/test/CodeGen/AMDGPU extract_vector_dynelt_subbyte.ll

Add poison test
DeltaFile
+1,340-0llvm/test/CodeGen/AMDGPU/extract_vector_dynelt_subbyte.ll
+1,340-01 files

LLVM/project 49b09a9 — llvm/test/CodeGen/AMDGPU extract_vector_dynelt_subbyte.ll

[AMDGPU] Add tests for dynamic extract from sub byte element vectors. NFC

A dynamic extract from an illegal vector of i1/i2/i4 elements can be
lowered to a word select and shift instead of going through scratch.
Cover several widths, uniform and divergent indices, SelectionDAG and
GlobalISel, and negative cases.
DeltaFile
+2,565-0llvm/test/CodeGen/AMDGPU/extract_vector_dynelt_subbyte.ll
+2,565-01 files

LLVM/project 3540393 — llvm/lib/Transforms/Scalar LoopPredication.cpp, llvm/test/Transforms/LoopPredication assume-cache.ll

[LoopPredication] Register inserted assumptions with the AssumptionCache (#247964)

When widening a guard, LoopPredication inserts an llvm.assume of the
guard's old condition (on by default), but did not register it with the
AssumptionCache. The cache is never invalidated, so it was missing these
assumptions for the rest of the pipeline. This registers them in both
places that insert one.

Another follow-up to #245493.
DeltaFile
+74-0llvm/test/Transforms/LoopPredication/assume-cache.ll
+8-5llvm/lib/Transforms/Scalar/LoopPredication.cpp
+82-52 files

LLVM/project dfb992c — libcxxabi/src private_typeinfo.h private_typeinfo.cpp

[libc++abi] Merge dst_type_might_be_derived_from_static_type into path_dst_ptr_to_static_ptr
DeltaFile
+17-32libcxxabi/src/private_typeinfo.cpp
+1-1libcxxabi/src/private_typeinfo.h
+18-332 files