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

Run:explore-bc8218b282-20261015-075519
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 bc8218b282
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       0x000056236597d54b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1  llc       0x000056236597a3f1 llvm::sys::RunSignalHandlers() + 369
2  llc       0x000056236597dfcb
3  libc.so.6 0x00007f6677445330
4  libc.so.6 0x00007f667749ec0c pthread_kill + 284
5  libc.so.6 0x00007f667744527e gsignal + 30
6  libc.so.6 0x00007f66774288ff abort + 223
7  libc.so.6 0x00007f667742881b
8  libc.so.6 0x00007f667743b517
9  llc       0x0000562367ac6f06 llvm::LegalizeRuleSet::apply(llvm::LegalityQuery const&) const + 2374
10 llc       0x0000562367ac7f32 llvm::LegalizerInfo::getAction(llvm::MachineInstr const&, llvm::MachineRegisterInfo const&) const + 1138
11 llc       0x0000562367a75b01 llvm::LegalizerHelper::legalizeInstrStep(llvm::MachineInstr&, llvm::LostDebugLocObserver&) + 257
12 llc       0x0000562367a6a049 llvm::legalizeMachineFunction(llvm::MachineFunction&, llvm::LegalizerInfo const&, llvm::ArrayRef<llvm::GISelChangeObserver*>, llvm::LostDebugLocObserver&, llvm::MachineIRBuilder&, llvm::LibcallLoweringInfo const*, llvm::GISelValueTracking*) + 1753
13 llc       0x0000562367a6bd90
14 llc       0x0000562367a6b9b2 llvm::LegalizerLegacy::runOnMachineFunction(llvm::MachineFunction&) + 242
15 llc       0x0000562365f449ed llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 653
16 llc       0x0000562365cd4d37 llvm::FPPassManager::runOnFunction(llvm::Function&) + 871
17 llc       0x0000562365cdd232 llvm::FPPassManager::runOnModule(llvm::Module&) + 50
18 llc       0x0000562365cd5ae0 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 2000
19 llc       0x0000562365984ba8 llcMain + 12056
20 llc       0x00005623658bf6af main + 63
21 libc.so.6 0x00007f667742a1ca
22 libc.so.6 0x00007f667742a28b __libc_start_main + 139
23 llc       0x00005623658bf5a5 _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.