Add LLVMExtractFirstVectorElement() function (and use it).
For cases where it turns out that we just need the first element of a vector (e.g. because we've determined that all of the values are equal), it's often more efficient to only compute that one value with scalar operations than to compute the whole vector's worth and then just use one value. This function tries to rewrite a vector computation to the scalar equivalent, if possible. (Partial work-around to http://llvm.org/bugs/show_bug.cgi?id=11775.) Note that sometimes this is the wrong thing to do--if we need the entire vector value for other purposes, for example.
This commit is contained in:
11
llvmutil.h
11
llvmutil.h
@@ -239,6 +239,17 @@ void LLVMFlattenInsertChain(llvm::InsertElementInst *ie, int vectorWidth,
|
||||
on. */
|
||||
extern void LLVMDumpValue(llvm::Value *v);
|
||||
|
||||
/** Given a vector-typed value, this function returns the value of its
|
||||
first element. Rather than just doing the straightforward thing of
|
||||
using a single extractelement instruction to do this, this function
|
||||
tries to rewrite the computation for the first element in scalar form;
|
||||
this is generally more efficient than computing the entire vector's
|
||||
worth of values just to extract the first element, in cases where only
|
||||
the first element's value is needed.
|
||||
*/
|
||||
extern llvm::Value *LLVMExtractFirstVectorElement(llvm::Value *v,
|
||||
llvm::Instruction *insertBefore);
|
||||
|
||||
/** This function takes two vectors, expected to be the same length, and
|
||||
returns a new vector of twice the length that represents concatenating
|
||||
the two of them. */
|
||||
|
||||
Reference in New Issue
Block a user