[cfe-commits] r61766 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGen/ocu-vector.c

Daniel Dunbar daniel at zuster.org
Mon Jan 5 14:55:36 PST 2009


Author: ddunbar
Date: Mon Jan  5 16:55:36 2009
New Revision: 61766

URL: http://llvm.org/viewvc/llvm-project?rev=61766&view=rev
Log:
Remainder is only valid on integer vector operands.

Improve ext vector test case.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGen/ocu-vector.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=61766&r1=61765&r2=61766&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan  5 16:55:36 2009
@@ -2374,8 +2374,11 @@
 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);
   

Modified: cfe/trunk/test/CodeGen/ocu-vector.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ocu-vector.c?rev=61766&r1=61765&r2=61766&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/ocu-vector.c (original)
+++ cfe/trunk/test/CodeGen/ocu-vector.c Mon Jan  5 16:55:36 2009
@@ -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 @@
 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 @@
     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 @@
   *out = ((float4) {a,b,c,d});
 }
 
-static void test5(float4 *out) {
+void test5(float4 *out) {
   float a;
   float4 b;
   
@@ -46,3 +47,75 @@
   
   *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;
+}





More information about the cfe-commits mailing list