The assert() is making an assumption that the resulting shuffle mask will always select elements from both vectors, this is untrue in the case of two shuffles being folded if the former shuffle has a mask with undef elements in it. In such a case folding the shuffles might result in a mask which only selects from one of the vectors because the other elements (in the mask) are undef.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/InstCombine/foldSelectShuffleOfSelectShuffle.ll | ||
---|---|---|
3 ↗ | (On Diff #468906) | ...and move this test next to wherever the other tests for this transform are. |
llvm/test/Transforms/InstCombine/foldSelectShuffleOfSelectShuffle.ll | ||
---|---|---|
4 ↗ | (On Diff #468906) | ...and minimize the test :) No loads or globals are needed to show the bug (if this is filed as a bug somewhere, add a reference). define <4 x float> @identity_mask(<4 x float>%x, <4 x float> %y) { %s1 = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 0, i32 5, i32 undef, i32 undef> %s2 = shufflevector <4 x float> %s1, <4 x float> %x, <4 x i32> <i32 0, i32 undef, i32 6, i32 7> ret <4 x float> %s2 } |
Comment Actions
LGTM.
For reference, the bug was introduced with e239198cdbbf. Before that patch, the pattern would get reduced in multiple steps using demanded elements, so there's no difference in optimization on this kind of shuffle pattern AFAICT.
clang-format this please :)