[llvm] [GlobalISel] Add G_INSERT_VECTOR_ELT to computeNumSignBits (PR #213480)

Joel Walker via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 12:54:02 PDT 2026


Joel-Wwalker wrote:

Keeping this PR as the insert-only half; the extract case landed in #218283 and is dropped here. Rebased onto main, and the review comments are applied: the vector result goes through a temporary, and scalable vectors no longer bail. They take the minimum of the whole vector and the inserted value; only the constant-index lane split is skipped for them.

The implicit-truncation case still bails, as the SelectionDAG version does. Ignoring the inserted value there is not sound when its lane is demanded: for `%r:_(<4 x i16>) = G_INSERT_VECTOR_ELT %v, %val(i32), 0` with %v at 9 sign bits per lane and %val unknown, lane 0 has 1 sign bit. A version that skips %val reports 9 for %r, and an extract of lane 0 from it comes back as UINT_MAX because neither operand contributes. `signbits_implicit_trunc_unknown_val` pins both at 1.

@deepakshirkem thanks for offering. With those changes this covers the insert case, so closing #220842 is fine by me. Your call.

Assisted by Claude (Anthropic).


https://github.com/llvm/llvm-project/pull/213480


More information about the llvm-commits mailing list