Fix bugs in LLVMExtractFirstVectorElement().

When we're manually scalarizing the extraction of the first element
of a vector value, we need to be careful about handling constant values
and about where new instructions are inserted.  The old code was
sloppy about this, which in turn lead to invalid IR in some cases.
For example, the two bugs below were essentially due to generating
an extractelement inst from a zeroinitializer value and then inserting
it in the wrong bblock such that a phi node that used that value was
malformed.

Fixes issues #240 and #229.
This commit is contained in:
Matt Pharr
2012-04-19 09:45:04 -07:00
parent a2bb899a6b
commit 326c45fa17
3 changed files with 52 additions and 26 deletions

View File

@@ -274,8 +274,7 @@ extern void LLVMDumpValue(llvm::Value *v);
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);
extern llvm::Value *LLVMExtractFirstVectorElement(llvm::Value *v);
/** This function takes two vectors, expected to be the same length, and
returns a new vector of twice the length that represents concatenating