From 0d2bfec51da5b95020b87fc195a6f9b4b0fa04b9 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 5 Jan 2009 22:55:36 +0000 Subject: [PATCH] Remainder is only valid on integer vector operands. Improve ext vector test case. llvm-svn: 61766 --- clang/lib/Sema/SemaExpr.cpp | 7 ++- clang/test/CodeGen/ocu-vector.c | 81 +++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 42ef417de472..5e07dfe8d880 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2374,8 +2374,11 @@ inline QualType Sema::CheckMultiplyDivideOperands( inline QualType Sema::CheckRemainderOperands( Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign) { - if (lex->getType()->isVectorType() || rex->getType()->isVectorType()) - return CheckVectorOperands(Loc, lex, rex); + if (lex->getType()->isVectorType() || rex->getType()->isVectorType()) { + if (lex->getType()->isIntegerType() && rex->getType()->isIntegerType()) + return CheckVectorOperands(Loc, lex, rex); + return InvalidOperands(Loc, lex, rex); + } QualType compType = UsualArithmeticConversions(lex, rex, isCompAssign); diff --git a/clang/test/CodeGen/ocu-vector.c b/clang/test/CodeGen/ocu-vector.c index 24ea17d527aa..657b28585353 100644 --- a/clang/test/CodeGen/ocu-vector.c +++ b/clang/test/CodeGen/ocu-vector.c @@ -2,6 +2,7 @@ typedef __attribute__(( ext_vector_type(4) )) float float4; typedef __attribute__(( ext_vector_type(2) )) float float2; +typedef __attribute__(( ext_vector_type(4) )) int int4; float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 }; @@ -13,7 +14,7 @@ float2 vec2, vec2_2; float4 vec4, vec4_2; float f; -static void test2() { +void test2() { vec2 = vec4.rg; // shorten f = vec2.x; // extract elt vec4 = vec4.yyyy; // splat @@ -22,11 +23,11 @@ static void test2() { vec2.yx = vec2; // reverse } -static void test3(float4 *out) { +void test3(float4 *out) { *out = ((float4) {1.0f, 2.0f, 3.0f, 4.0f }); } -static void test4(float4 *out) { +void test4(float4 *out) { float a = 1.0f; float b = 2.0f; float c = 3.0f; @@ -34,7 +35,7 @@ static void test4(float4 *out) { *out = ((float4) {a,b,c,d}); } -static void test5(float4 *out) { +void test5(float4 *out) { float a; float4 b; @@ -46,3 +47,75 @@ static void test5(float4 *out) { *out = b; } + +void test6(float4 *ap, float4 *bp, float c) { + float4 a = *ap; + float4 b = *bp; + + a = a + b; + a = a - b; + a = a * b; + a = a / b; + + a = a + c; + a = a - c; + a = a * c; + a = a / c; + + a += b; + a -= b; + a *= b; + a /= b; + + a += c; + a -= c; + a *= c; + a /= c; + + int4 cmp; + + cmp = a < b; + cmp = a <= b; + cmp = a < b; + cmp = a >= b; + cmp = a == b; + cmp = a != b; +} + +void test7(int4 *ap, int4 *bp, int c) { + int4 a = *ap; + int4 b = *bp; + + a = a + b; + a = a - b; + a = a * b; + a = a / b; + a = a % b; + + a = a + c; + a = a - c; + a = a * c; + a = a / c; + a = a % c; + + a += b; + a -= b; + a *= b; + a /= b; + a %= b; + + a += c; + a -= c; + a *= c; + a /= c; + a %= c; + + int4 cmp; + + cmp = a < b; + cmp = a <= b; + cmp = a < b; + cmp = a >= b; + cmp = a == b; + cmp = a != b; +}