From: David Tweed Date: Thu, 10 Jan 2013 09:11:33 +0000 (+0000) Subject: Testing with a full OpenCL compiler (based on clang) reveals r71734 missed X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f20318f9e27a064bdd9a3fbb51d2c3a4a4f3ac2e;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172047 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index ae7518a2b9..fb5f58ddbb 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -2368,8 +2368,12 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) { } Value *ScalarExprEmitter::GetWidthMinusOneValue(Value* LHS,Value* RHS) { - unsigned Width = cast(LHS->getType())->getBitWidth(); - return llvm::ConstantInt::get(RHS->getType(), Width - 1); + llvm::IntegerType *Ty; + if (llvm::VectorType *VT = dyn_cast(LHS->getType())) + Ty = cast(VT->getElementType()); + else + Ty = cast(LHS->getType()); + return llvm::ConstantInt::get(RHS->getType(), Ty->getBitWidth() - 1); } Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) {