[mlir][vector] Fold vector extract from insert when trailing unit dims (#192109)
Upstreamed from https://github.com/iree-org/iree/pull/23789
Folds vector.extract from vector.insert when the extract position is a
prefix of the insert position and the remaining (un-indexed) dimensions
of the extracted sub-vector are all size 1. In that case the extracted
value is fully determined by the inserted value.
Example:
%ins = vector.insert %s, %v [3, 0] : f32 into vector<16x1xf32>
%ext = vector.extract %ins [3] : vector<1xf32> from vector<16x1xf32>
folds to:
%ext = vector.broadcast %s : f32 to vector<1xf32>
Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>