@@ -182,9 +182,10 @@ static void fixI8UseChain(Instruction &I,
182182 ElementType = ArrTy->getArrayElementType ();
183183
184184 ConstantInt *Offset = dyn_cast<ConstantInt>(GEP->getOperand (1 ));
185- // Note: the only way to convert an i8 offset to an i32 offset without
186- // emitting code Would be to emit code. We sould expect this value to be a
187- // ConstantInt since Offsets are very regulalrly converted.
185+ // Note: i8 to i32 offset conversion without emitting IR requires constant
186+ // ints. Since offset conversion is common, we can safely assume Offset is
187+ // always a ConstantInt, so no need to have a conditional bail out on
188+ // nullptr, instead assert this is the case.
188189 assert (Offset && " Offset is expected to be a ConstantInt" );
189190 uint32_t ByteOffset = Offset->getZExtValue ();
190191 uint32_t ElemSize = GEP->getDataLayout ().getTypeAllocSize (ElementType);
@@ -210,20 +211,19 @@ static void upcastI8AllocasAndUses(Instruction &I,
210211 auto ProcessLoad = [&](LoadInst *Load) {
211212 for (User *LU : Load->users ()) {
212213 Type *Ty = nullptr ;
213- if (auto *Cast = dyn_cast<CastInst>(LU)) {
214+ if (CastInst *Cast = dyn_cast<CastInst>(LU))
214215 Ty = Cast->getType ();
215- } else if (auto *CI = dyn_cast<CallInst>(LU)) {
216+ else if (CallInst *CI = dyn_cast<CallInst>(LU)) {
216217 if (CI->getIntrinsicID () == Intrinsic::memset)
217218 Ty = Type::getInt32Ty (CI->getContext ());
218219 }
219220
220221 if (!Ty)
221222 continue ;
222223
223- if (!SmallestType || Ty-> getPrimitiveSizeInBits () <
224- SmallestType->getPrimitiveSizeInBits ()) {
224+ if (!SmallestType ||
225+ Ty-> getPrimitiveSizeInBits () < SmallestType->getPrimitiveSizeInBits ())
225226 SmallestType = Ty;
226- }
227227 }
228228 };
229229
@@ -232,9 +232,8 @@ static void upcastI8AllocasAndUses(Instruction &I,
232232 ProcessLoad (Load);
233233 else if (auto *GEP = dyn_cast<GetElementPtrInst>(U)) {
234234 for (User *GU : GEP->users ()) {
235- if (auto *Load = dyn_cast<LoadInst>(GU)) {
235+ if (auto *Load = dyn_cast<LoadInst>(GU))
236236 ProcessLoad (Load);
237- }
238237 }
239238 }
240239 }
0 commit comments