From cfa4f4a10229b8a516e602e890a0487462959a54 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Fri, 23 Aug 2002 03:21:01 +0000 Subject: [PATCH] Simplify previous hack slightly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3490 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/TargetData.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 48fca1ebdf4..6786af3982d 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -164,13 +164,11 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, // Get the array index and the size of each array element. // Both must be known constants, or this will fail. - // Also, the arrayIdx needs to be sign-extended from uint - // to the machine register size if the reg. size > sizeof(uint). + // Also, the arrayIdx needs to be sign-extended from 32 bits to uint64_t + // since uint is not normally sign-extended when cast to uint64_t. uint64_t elementSize = this->getTypeSize(Ty); uint64_t arrayIdx = cast(Idx[CurIDX])->getValue(); - if (getIntegerRegize() > sizeof(uint)) { - arrayIdx = (uint64_t) (int) arrayIdx; // sign-extend from 32 to 64 bits - } + arrayIdx = (uint64_t) (int) arrayIdx; // sign-extend from 32 to 64 bits Result += arrayIdx * elementSize; } else if (const StructType *STy = dyn_cast(Ty)) {