We have the following interface in IRBuilder.h:
Value *CreateVectorSplat( unsigned NumElts , Value * V , const Twine & Name = "" ) { ..}
This function creates 2 instructions - “insertelement” and “shuffle” with all-zero mask.
Now I'm adding
Value *getSplatValue(Value *Val)
This function recognizes the pattern - insertelement+shuffle and returns the splat value (or nullptr).
It also returns a splat value form ConstantDataVector, for completeness.
( I don't know why functions in this file are not wrapped with "namespace llvm")