Simplify ExtVectorElementExpr::containsDuplicateElements().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84380 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-10-17 23:53:04 +00:00
Родитель bfec576b1b
Коммит 150274299b
1 изменённых файлов: 7 добавлений и 13 удалений

Просмотреть файл

@ -1744,26 +1744,20 @@ unsigned ExtVectorElementExpr::getNumElements() const {
/// containsDuplicateElements - Return true if any element access is repeated. /// containsDuplicateElements - Return true if any element access is repeated.
bool ExtVectorElementExpr::containsDuplicateElements() const { bool ExtVectorElementExpr::containsDuplicateElements() const {
const char *compStr = Accessor->getName(); llvm::StringRef Comp = Accessor->getNameStr();
unsigned length = Accessor->getLength();
// Halving swizzles do not contain duplicate elements. // Halving swizzles do not contain duplicate elements.
if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") || if (Comp == "hi" || Comp == "lo" || Comp == "even" || Comp == "odd")
!strcmp(compStr, "even") || !strcmp(compStr, "odd"))
return false; return false;
// Advance past s-char prefix on hex swizzles. // Advance past s-char prefix on hex swizzles.
if (*compStr == 's' || *compStr == 'S') { if (Comp[0] == 's' || Comp[0] == 'S')
compStr++; Comp = Comp.substr(1);
length--;
}
for (unsigned i = 0; i != length-1; i++) { for (unsigned i = 0, e = Comp.size(); i != e; ++i)
const char *s = compStr+i; if (Comp.substr(i + 1).find(Comp[i]) != llvm::StringRef::npos)
for (const char c = *s++; *s; s++)
if (c == *s)
return true; return true;
}
return false; return false;
} }