Skip to content

Autoharness ICE: SIMD codegen unwraps vector length for a generic helper instantiated with a scalar #4919

Description

@feliperodri

Summary

kani autoharness crashes on a generic function whose body calls SIMD intrinsics but whose T has no SIMD bound. Autoharness picks T = i32, and the SIMD comparison codegen then unwraps the vector length of a scalar:

thread 'rustc' panicked at kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs:1548:29:
called `Option::unwrap()` on a `None` value
[Kani] current codegen item: codegen_function: lib::imin::<i32>

Reproducer

#![feature(core_intrinsics)]
#![allow(internal_features)]

pub unsafe fn imin<T: Copy>(a: T, b: T) -> T {
    let mask: T = core::intrinsics::simd::simd_lt(a, b);
    core::intrinsics::simd::simd_select(mask, a, b)
}
$ kani autoharness -Z autoharness lib.rs --only-codegen
thread 'rustc' panicked at kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs:1548:29:
called `Option::unwrap()` on a `None` value

Line 1548 is unchanged on main.

Cause

if arg1.typ().len().unwrap() != ret_typ.len().unwrap() {

len() is None for a non-vector type. rustc itself rejects simd_lt::<i32> at monomorphization, so this instantiation can never be real code — Kani should report it, not crash.

Suggested fix

Either:

The first avoids the dead instantiation; the second stops any other unbounded generic SIMD helper from aborting a whole run.

Why this matters for the standard library

core::core_arch::simd::simd_imin<T: Copy> (stdarch, nightly-2026-08-21) has exactly this shape. With #4819, #4848, #4869 and #4801 applied, autoharness over the whole standard library gets far enough to reach it, and core then fails codegen. This is what still blocks the unfiltered autoharness path — the Kani Metrics, Kani List and autoharness-analyzer jobs in model-checking/verify-rust-std#687, which pass no --include-pattern. I searched for existing issues and PRs on this and found none.

Activity

  1. srivatsansamraj commented on Sep 30, 2026

    @srivatsansamraj
    Contributor

    #4922 takes the second option: a SIMD intrinsic whose operand is not a SIMD type is reported as unsupported instead of panicking. I missed this issue and opened #4921 for the same crash, now closed as a duplicate.

    With #4922 and #4856 added to the four fixes above, the autoharness listing CI runs (kani autoharness --list --std) completes on model-checking/verify-rust-std#687's library: 26,909 functions with harnesses, 14,326 without. On nightly-2026-08-21, #4856 needs layout.value_repr / ValueRepr written as layout.abi / ValueAbi.

  2. added 2 commits that reference this issue on Oct 1, 2026
    1f63979
    5193da6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions