Testing with a full OpenCL compiler (based on clang) reveals r71734 missed

difference between type widths of a vector and the width of one of its elements
in the case of vector shifts. Use correct witdth in the vector case.

llvm-svn: 172047
This commit is contained in:
David Tweed 2013-01-10 09:11:33 +00:00
parent 8e68b792b4
commit 9fb566c076
1 changed files with 6 additions and 2 deletions

View File

@ -2368,8 +2368,12 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) {
}
Value *ScalarExprEmitter::GetWidthMinusOneValue(Value* LHS,Value* RHS) {
unsigned Width = cast<llvm::IntegerType>(LHS->getType())->getBitWidth();
return llvm::ConstantInt::get(RHS->getType(), Width - 1);
llvm::IntegerType *Ty;
if (llvm::VectorType *VT = dyn_cast<llvm::VectorType>(LHS->getType()))
Ty = cast<llvm::IntegerType>(VT->getElementType());
else
Ty = cast<llvm::IntegerType>(LHS->getType());
return llvm::ConstantInt::get(RHS->getType(), Ty->getBitWidth() - 1);
}
Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) {