1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

When lowering an inbounds gep, the intermediate adds can have

unsigned overflow (e.g. due to a negative array index), but
the scales on array size multiplications are known to not
sign wrap.

llvm-svn: 125409
This commit is contained in:
Chris Lattner 2011-02-11 21:37:43 +00:00
parent 1ba77f9624
commit 6c0014cd4a

View File

@ -420,8 +420,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
if (Size)
Result = Builder->CreateAdd(Result, ConstantInt::get(IntPtrTy, Size),
GEP->getName()+".offs",
isInBounds /*NUW*/);
GEP->getName()+".offs");
continue;
}
@ -430,8 +429,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/);
Scale = ConstantExpr::getMul(OC, Scale, isInBounds/*NUW*/);
// Emit an add instruction.
Result = Builder->CreateAdd(Result, Scale, GEP->getName()+".offs",
isInBounds /*NUW*/);
Result = Builder->CreateAdd(Result, Scale, GEP->getName()+".offs");
continue;
}
// Convert to correct type.
@ -444,8 +442,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
}
// Emit an add instruction.
Result = Builder->CreateAdd(Op, Result, GEP->getName()+".offs",
isInBounds /*NUW*/);
Result = Builder->CreateAdd(Op, Result, GEP->getName()+".offs");
}
return Result;
}