[InstSimplify] fold extractelement of splat with variable extract index
authorSanjay Patel <spatel@rotateright.com>
Mon, 5 Jul 2021 12:14:20 +0000 (08:14 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 5 Jul 2021 12:19:40 +0000 (08:19 -0400)
commit3d3c0ed9323ba387dd6030337c672d2c9c4816f0
treed6779a6cd2f250df09110f0d26423eceec116a74
parentde8274a1b912687ca7b182ce28b34b0e66b2b0e3
[InstSimplify] fold extractelement of splat with variable extract index

We already have a fold for variable index with constant vector,
but if we can determine a scalar splat value, then it does not
matter whether that value is constant or not.

We overlooked this fold in D102404 and earlier patches,
but the fixed vector variant is shown in:
https://llvm.org/PR50817

Alive2 agrees on that:
https://alive2.llvm.org/ce/z/HpijPC

The same logic applies to scalable vectors.

Differential Revision: https://reviews.llvm.org/D104867
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/extract-element.ll
llvm/test/Transforms/InstSimplify/vscale-inseltpoison.ll
llvm/test/Transforms/InstSimplify/vscale.ll