From: Daniel Dunbar Date: Mon, 5 Jan 2009 22:55:36 +0000 (+0000) Subject: Remainder is only valid on integer vector operands. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=523aa600bee6b4de874cdc9dd0269c97cb7c912e;p=clang Remainder is only valid on integer vector operands. Improve ext vector test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61766 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 42ef417de4..5e07dfe8d8 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/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/test/CodeGen/ocu-vector.c b/test/CodeGen/ocu-vector.c index 24ea17d527..657b285853 100644 --- a/test/CodeGen/ocu-vector.c +++ b/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; +}