[cfe-commits] r148452 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaExpr.cpp test/CodeGenOpenCL/vector_logops.cl
Tanya Lattner
tonic at nondot.org
Wed Jan 18 17:16:16 PST 2012
Author: tbrethou
Date: Wed Jan 18 19:16:16 2012
New Revision: 148452
URL: http://llvm.org/viewvc/llvm-project?rev=148452&view=rev
Log:
A few style changes.
Change CheckVectorLogicalOperands to pass params by ref.
Add another test case.
Added:
cfe/trunk/test/CodeGenOpenCL/vector_logops.cl
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=148452&r1=148451&r2=148452&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 18 19:16:16 2012
@@ -5938,7 +5938,7 @@
QualType GetSignedVectorType(QualType V);
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
SourceLocation Loc, bool isRelational);
- QualType CheckVectorLogicalOperands(ExprResult LHS, ExprResult RHS,
+ QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
SourceLocation Loc);
/// type checking declaration initializers (C99 6.7.8)
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=148452&r1=148451&r2=148452&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan 18 19:16:16 2012
@@ -6944,9 +6944,8 @@
return GetSignedVectorType(LHSType);
}
-QualType Sema::CheckVectorLogicalOperands(ExprResult LHS, ExprResult RHS,
- SourceLocation Loc)
-{
+QualType Sema::CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc) {
// Ensure that either both operands are of the same vector type, or
// one operand is of a vector type and the other is of its element type.
QualType vType = CheckVectorOperands(LHS, RHS, Loc, false);
@@ -8281,9 +8280,7 @@
Input = ImpCastExprToType(Input.take(), Context.BoolTy,
ScalarTypeToBooleanCastKind(resultType));
}
- }
- else if (resultType->isExtVectorType()) {
- // Handle vector types.
+ } else if (resultType->isExtVectorType()) {
// Vector logical not returns the signed variant of the operand type.
resultType = GetSignedVectorType(resultType);
break;
Added: cfe/trunk/test/CodeGenOpenCL/vector_logops.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vector_logops.cl?rev=148452&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/vector_logops.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/vector_logops.cl Wed Jan 18 19:16:16 2012
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O3 %s -emit-llvm -o - | FileCheck %s
+
+typedef int int2 __attribute((ext_vector_type(2)));
+
+int test1()
+{
+ int2 a = (int2)(1,0);
+ int2 b = (int2)(1,1);
+ return (a&&b).x + (a||b).y;
+ // CHECK: ret i32 -2
+}
+
+int test2()
+{
+ int2 a = (int2)(1,0);
+ return (!a).y;
+ // CHECK: ret i32 -1
+}
+
More information about the cfe-commits
mailing list