]> granicus.if.org Git - clang/commitdiff
A couple more vector component access fixes.
authorNate Begeman <natebegeman@mac.com>
Sun, 18 Jan 2009 02:01:21 +0000 (02:01 +0000)
committerNate Begeman <natebegeman@mac.com>
Sun, 18 Jan 2009 02:01:21 +0000 (02:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62443 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/CodeGen/ext-vector.c
test/Coverage/c-language-features.inc

index 6540b2ccc367ee997bc69e04a875022e53642310..4dd06b924a2bced92ce8b012529309eb919db642 100644 (file)
@@ -1160,6 +1160,17 @@ unsigned ExtVectorElementExpr::getNumElements() const {
 bool ExtVectorElementExpr::containsDuplicateElements() const {
   const char *compStr = Accessor.getName();
   unsigned length = Accessor.getLength();
+
+  // Halving swizzles do not contain duplicate elements.
+  if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") || 
+      !strcmp(compStr, "even") || !strcmp(compStr, "odd"))
+    return false;
+  
+  // Advance past s-char prefix on hex swizzles.
+  if (*compStr == 's') {
+    compStr++;
+    length--;
+  }
   
   for (unsigned i = 0; i != length-1; i++) {
     const char *s = compStr+i;
index 657b2858535384767e9101fc5050aad9f731235d..ae877edb815d42106067f23674cfc61326dfc4b8 100644 (file)
@@ -15,7 +15,7 @@ float4 vec4, vec4_2;
 float f;
 
 void test2() {
-    vec2 = vec4.rg;  // shorten
+    vec2 = vec4.xy;  // shorten
     f = vec2.x;      // extract elt
     vec4 = vec4.yyyy;  // splat
     
index 6944b9d65e9ffca61267f2151c8b9c05bf97c789..9a52e56c21d5d98994d9789bc9f47124148ab3d0 100644 (file)
@@ -136,7 +136,7 @@ typedef __attribute__((ext_vector_type(4))) float float4;
 void f5() {
   float4 t0 = (float4) { 0, 1, 2, 3 };
   float4 t1 = t0;
-  t0.lo.e = t1.hi.x;
+  t0.lo.even = t1.hi.x;
 }
 
 void f6() {