crash: Assertion failed: (mutationIsSane(Rule, Query, Mutation) && "legality mutation invalid for match"), function apply, file LegalizerInfo.cpp

Run:main-04ca53e65f-20261014-105623
Kind:crash
Category:Assertion failed: (mutationIsSane(Rule, Query, Mutation) && "legality mutation invalid for match"), function apply, file LegalizerInfo.cpp
Occurrences:4 in 4 configs, 2 test files
Snippet from:rv32zbb.ll via full input + llvm-reduce
Config:-mtriple=riscv32 -mattr=+zbb -verify-machineinstrs
Local check:reproduces at 04ca53e65f
Compiler Explorer:https://godbolt.org/z/zM731345G (llc-assertions-trunk, checked 2026-10-14 11:03 UTC): G reproduces

Snippet:

define <2 x i32> @ctpop_v2i32(<2 x i32> %a) {
  %1 = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %a)
  ret <2 x i32> %1
}

; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0

attributes #0 = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }

Compiler Explorer panes:

PaneOptionsExitInstsstderr
GlobalISel-mtriple=riscv32 -mattr=+zbb -verify-machineinstrs -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel.*1340llc: /root/llvm-project/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp:203: llvm::LegalizeActionStep llvm::LegalizeRuleSet::apply(const llvm::LegalityQuery&) const: Assertion `mutationIsSane(Rule, Query, Mutation) && "legality mutation invalid for match"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
SelectionDAG (control)-mtriple=riscv32 -mattr=+zbb -verify-machineinstrs -global-isel=003-

Reproduce:

llc -mtriple=riscv32 -mattr=+zbb -verify-machineinstrs -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel.* snippet.ll -o -
llc -mtriple=riscv32 -mattr=+zbb -verify-machineinstrs -global-isel=0 snippet.ll -o -

Local llc output:

llc: /home/runner/work/llvm-fuzz/llvm-fuzz/llvm-project/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp:204: LegalizeActionStep llvm::LegalizeRuleSet::apply(const LegalityQuery &) const: Assertion `mutationIsSane(Rule, Query, Mutation) && "legality mutation invalid for match"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /home/runner/work/llvm-fuzz/llvm-fuzz/llvm-project/build/bin/llc -mtriple=riscv32 -mattr=+zbb -verify-machineinstrs -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel.* -o -
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'Legalizer' on function '@ctpop_v2i32'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  llc       0x00005561a224d79b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1  llc       0x00005561a224a641 llvm::sys::RunSignalHandlers() + 369
2  llc       0x00005561a224e21b
3  libc.so.6 0x00007f025f245330
4  libc.so.6 0x00007f025f29ec0c pthread_kill + 284
5  libc.so.6 0x00007f025f24527e gsignal + 30
6  libc.so.6 0x00007f025f2288ff abort + 223
7  libc.so.6 0x00007f025f22881b
8  libc.so.6 0x00007f025f23b517
9  llc       0x00005561a4392fe6 llvm::LegalizeRuleSet::apply(llvm::LegalityQuery const&) const + 2374
10 llc       0x00005561a4394012 llvm::LegalizerInfo::getAction(llvm::MachineInstr const&, llvm::MachineRegisterInfo const&) const + 1138
11 llc       0x00005561a4341be1 llvm::LegalizerHelper::legalizeInstrStep(llvm::MachineInstr&, llvm::LostDebugLocObserver&) + 257
12 llc       0x00005561a4336129 llvm::legalizeMachineFunction(llvm::MachineFunction&, llvm::LegalizerInfo const&, llvm::ArrayRef<llvm::GISelChangeObserver*>, llvm::LostDebugLocObserver&, llvm::MachineIRBuilder&, llvm::LibcallLoweringInfo const*, llvm::GISelValueTracking*) + 1753
13 llc       0x00005561a4337e70
14 llc       0x00005561a4337a92 llvm::LegalizerLegacy::runOnMachineFunction(llvm::MachineFunction&) + 242
15 llc       0x00005561a2814d2d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 653
16 llc       0x00005561a25a4cd7 llvm::FPPassManager::runOnFunction(llvm::Function&) + 871
17 llc       0x00005561a25ad1d2 llvm::FPPassManager::runOnModule(llvm::Module&) + 50
18 llc       0x00005561a25a5a80 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 2000
19 llc       0x00005561a2254df8 llcMain + 12056
20 llc       0x00005561a219062f main + 63
21 libc.so.6 0x00007f025f22a1ca
22 libc.so.6 0x00007f025f22a28b __libc_start_main + 139
23 llc       0x00005561a2190525 _start + 37

Occurrences (4):

InputFunctionConfig
rv32zbb.ll-mtriple=riscv32 -mattr=+zbb -verify-machineinstrs
rv32zbb.ll-mtriple=riscv32 -verify-machineinstrs
rv64zbb.ll-mtriple=riscv64 -mattr=+zbb -verify-machineinstrs
rv64zbb.ll-mtriple=riscv64 -verify-machineinstrs

Generated 2026-10-15 08:05 UTC.