[cfe-commits] r172047 - /cfe/trunk/lib/CodeGen/CGExprScalar.cpp

David Tweed david.tweed at arm.com
Thu Jan 10 01:58:56 PST 2013


Ideally yes, but it's a bit tricky in that the portion of OpenCL implemented OSS clang doesn't support enough OpenCL builttin types to specify vectors in the source. I did have a go at writing a test in standard OpenCL but the compiler choked on it; I'll have a look to see if I can generate vectors from some hack constructs.

 

Regards,

Dave

 

From: Chandler Carruth [mailto:chandlerc at google.com] 
Sent: 10 January 2013 09:32
To: David Tweed
Cc: llvm cfe
Subject: Re: [cfe-commits] r172047 - /cfe/trunk/lib/CodeGen/CGExprScalar.cpp

 

On Thu, Jan 10, 2013 at 1:11 AM, David Tweed <david.tweed at arm.com> wrote:

Author: davidtweed
Date: Thu Jan 10 03:11:33 2013
New Revision: 172047

URL: http://llvm.org/viewvc/llvm-project?rev=172047 <http://llvm.org/viewvc/llvm-project?rev=172047&view=rev> &view=rev
Log:
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.

 

This still needs a regression test case.

 


Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=172047 <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=172047&r1=172046&r2=172047&view=diff> &r1=172046&r2=172047&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jan 10 03:11:33 2013
@@ -2368,8 +2368,12 @@
 }

 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) {


_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130110/603cd033/attachment.html>


More information about the cfe-commits mailing list