aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2012-01-19 01:16:16 +0000
committerTanya Lattner <tonic@nondot.org>2012-01-19 01:16:16 +0000
commitb0f9dd22bf469028b2c40eab60ad1019c3e6089d (patch)
tree23b1ec627721401df241521cddd851ad4a406219
parentbcdd7d92883d771106e54357245733358eac9672 (diff)
A few style changes.
Change CheckVectorLogicalOperands to pass params by ref. Add another test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148452 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Sema/Sema.h2
-rw-r--r--lib/Sema/SemaExpr.cpp9
-rw-r--r--test/CodeGenOpenCL/vector_logops.cl19
3 files changed, 23 insertions, 7 deletions
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 1320a05176..c09d41af58 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -5938,7 +5938,7 @@ public:
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)
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 662971f7de..1bb4140bd0 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6944,9 +6944,8 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
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 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
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;
diff --git a/test/CodeGenOpenCL/vector_logops.cl b/test/CodeGenOpenCL/vector_logops.cl
new file mode 100644
index 0000000000..388f1d7eb7
--- /dev/null
+++ b/test/CodeGenOpenCL/vector_logops.cl
@@ -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
+}
+