[llvm-commits] [llvm] r52516 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Dan Gohman
gohman at apple.com
Thu Jun 19 17:53:00 PDT 2008
Author: djg
Date: Thu Jun 19 19:53:00 2008
New Revision: 52516
URL: http://llvm.org/viewvc/llvm-project?rev=52516&view=rev
Log:
Simplify the ComputeLinearIndex logic and fix a few bugs.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=52516&r1=52515&r2=52516&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Jun 19 19:53:00 2008
@@ -100,37 +100,31 @@
const unsigned *IndicesEnd,
unsigned CurIndex = 0) {
// Base case: We're done.
- if (Indices == IndicesEnd)
+ if (Indices && Indices == IndicesEnd)
return CurIndex;
- // Otherwise we need to recurse. A non-negative value is used to
- // indicate the final result value; a negative value carries the
- // complemented position to continue the search.
- CurIndex = ~CurIndex;
-
// Given a struct type, recursively traverse the elements.
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
- for (StructType::element_iterator EI = STy->element_begin(),
+ for (StructType::element_iterator EB = STy->element_begin(),
+ EI = EB,
EE = STy->element_end();
EI != EE; ++EI) {
- CurIndex = ComputeLinearIndex(TLI, *EI, Indices+1, IndicesEnd,
- ~CurIndex);
- if ((int)CurIndex >= 0)
- return CurIndex;
+ if (Indices && *Indices == unsigned(EI - EB))
+ return ComputeLinearIndex(TLI, *EI, Indices+1, IndicesEnd, CurIndex);
+ CurIndex = ComputeLinearIndex(TLI, *EI, 0, 0, CurIndex);
}
}
// Given an array type, recursively traverse the elements.
else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
const Type *EltTy = ATy->getElementType();
for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) {
- CurIndex = ComputeLinearIndex(TLI, EltTy, Indices+1, IndicesEnd,
- ~CurIndex);
- if ((int)CurIndex >= 0)
- return CurIndex;
+ if (Indices && *Indices == i)
+ return ComputeLinearIndex(TLI, EltTy, Indices+1, IndicesEnd, CurIndex);
+ CurIndex = ComputeLinearIndex(TLI, EltTy, 0, 0, CurIndex);
}
}
// We haven't found the type we're looking for, so keep searching.
- return CurIndex;
+ return CurIndex + 1;
}
/// ComputeValueVTs - Given an LLVM IR type, compute a sequence of
More information about the llvm-commits
mailing list