From 5fc1282c1822d692ed1681cdc4c315950c6eb1d8 Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Wed, 20 Apr 2011 21:48:16 +0000 Subject: [PATCH] Cleanup some code to better use an early return style in preparation for adding more cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129876 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 95c36c93ed6..984f5c85d8b 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -337,16 +337,20 @@ void ConvertToScalarInfo::MergeInType(const Type *In, uint64_t Offset, unsigned EltSize = In->getPrimitiveSizeInBits()/8; if (IsLoadOrStore && EltSize == AllocaSize) return; + // If we're accessing something that could be an element of a vector, see // if the implied vector agrees with what we already have and if Offset is // compatible with it. - if (Offset % EltSize == 0 && AllocaSize % EltSize == 0 && - (VectorTy == 0 || - cast(VectorTy)->getElementType() - ->getPrimitiveSizeInBits()/8 == EltSize)) { - if (VectorTy == 0) + if (Offset % EltSize == 0 && AllocaSize % EltSize == 0) { + if (!VectorTy) { VectorTy = VectorType::get(In, AllocaSize/EltSize); - return; + return; + } + + unsigned CurrentEltSize = cast(VectorTy)->getElementType() + ->getPrimitiveSizeInBits()/8; + if (EltSize == CurrentEltSize) + return; } }