[Analysis] add query to get splat value from array of ints
authorSanjay Patel <spatel@rotateright.com>
Wed, 5 Feb 2020 19:18:13 +0000 (14:18 -0500)
committerSanjay Patel <spatel@rotateright.com>
Wed, 5 Feb 2020 19:55:02 +0000 (14:55 -0500)
commit686a038ed8f96e5539c54fea28aedac63145cf71
tree4ca290a7ca8de9629664f056227ac636dbc9835c
parent043e4787211609e987799050ba2944b77a53ddb5
[Analysis] add query to get splat value from array of ints

I was debug stepping through an x86 shuffle lowering and
noticed we were doing an N^2 search for splat index. I
didn't find the equivalent functionality anywhere else in
LLVM, so here's a helper that takes an array of int and
returns a splatted index while ignoring undefs (any
negative value).

This might also be used inside existing
ShuffleVectorInst/ShuffleVectorSDNode functions and/or
help with D72467.

Differential Revision: https://reviews.llvm.org/D74064
llvm/include/llvm/Analysis/VectorUtils.h
llvm/lib/Analysis/VectorUtils.cpp
llvm/unittests/Analysis/VectorUtilsTest.cpp