[SCCP] Use mergeInValue instead of markConstant when folding CastInst (#173190)
Fixes #173180
The crash occurs when a vector constant refines its value during
iterative analysis.
In `SCCPInstVisitor::visitCastInst`, the logic for folding constants
through a `CastInst` uses `markConstant`. This function is strictly
designed for initial assignments and contains an assertion that prevents
a lattice element from being updated with a different constant pointer.
During the analysis of loops or complex data flows, a vector constant
may "refine." For example:
First Pass: SCCP identifies a value as `<4 x i64> {poison, poison,
poison, 0}`.
Second Pass: The value refines to `<4 x i64> zeroinitializer`.
[10 lines not shown]
[LV][IRBuilder] Allow implicit truncation of step vector (#173229)
LV can create step vectors that wrap around, e.g. `step-vector i1` with
VF>2. Allow truncation when creating the vector constant to avoid an
assertion failure with https://github.com/llvm/llvm-project/pull/171456.
After https://github.com/llvm/llvm-project/pull/173494 the definition of
the llvm.stepvector intrinsic has been changed to make it have wrapping
semantics, so the semantics for the fixed and scalable case match now.
[LLVM][LangRef] Redefine out-of-range stepvector values as being truncated. (#173494)
The LangRef current defines out-of-range stepvector values as poison.
This property is at odds with both the expansion used for fixed-length
vectors and the equivalent ISD node, both of which implicitly truncate
out-of-range values.