From: Nate Begeman Date: Sun, 18 Jan 2009 02:01:21 +0000 (+0000) Subject: A couple more vector component access fixes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=190d6a25393995b42e32086949a68285ee423fb9;p=clang A couple more vector component access fixes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62443 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 6540b2ccc3..4dd06b924a 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -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; diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c index 657b285853..ae877edb81 100644 --- a/test/CodeGen/ext-vector.c +++ b/test/CodeGen/ext-vector.c @@ -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 diff --git a/test/Coverage/c-language-features.inc b/test/Coverage/c-language-features.inc index 6944b9d65e..9a52e56c21 100644 --- a/test/Coverage/c-language-features.inc +++ b/test/Coverage/c-language-features.inc @@ -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() {