Extracting a splat value from vector instruction.

Hi,

We have a function 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 want to add
Value *getSplatValue(Value *Val). This function will try to recognize the pattern - insertelement+shuffle and return the splat value (or nullptr).
I suppose, this interface should be useful. Do you agree with me?

If yes, where should I put it? May it be I can define a new class VectorInst and put this interface there?
Thank you.

  • Elena

From: "Elena Demikhovsky" <elena.demikhovsky@intel.com>
To: llvmdev@cs.uiuc.edu
Sent: Thursday, July 9, 2015 7:10:48 AM
Subject: [LLVMdev] Extracting a splat value from vector instruction.

Hi,

We have a function 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 want to add
Value *getSplatValue(Value *Val). This function will try to recognize
the pattern - insertelement+shuffle and return the splat value (or
nullptr).
I suppose, this interface should be useful. Do you agree with me?

If yes, where should I put it? May it be I can define a new class
VectorInst and put this interface there?

It does sound useful, but I think you might as well put it in include/llvm/Analysis/VectorUtils.h as a static helper function. I don't think we need a new artificial subclass just for this functionality.

-Hal

Thank you. I submitted the code for review.
http://reviews.llvm.org/D11124

- Elena