mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-13 16:03:58 +00:00
Minor code simplification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
479a778590
commit
9ed1a3cddb
@ -3183,18 +3183,18 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
|
||||
/// operations. This allows them to be analyzed by regular SCEV code.
|
||||
///
|
||||
const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
||||
|
||||
// Don't blindly transfer the inbounds flag from the GEP instruction to the
|
||||
// Add expression, because the Instruction may be guarded by control flow
|
||||
// and the no-overflow bits may not be valid for the expression in any
|
||||
// context.
|
||||
bool isInBounds = GEP->isInBounds();
|
||||
|
||||
Type *IntPtrTy = getEffectiveSCEVType(GEP->getType());
|
||||
Value *Base = GEP->getOperand(0);
|
||||
// Don't attempt to analyze GEPs over unsized objects.
|
||||
if (!cast<PointerType>(Base->getType())->getElementType()->isSized())
|
||||
return getUnknown(GEP);
|
||||
|
||||
// Don't blindly transfer the inbounds flag from the GEP instruction to the
|
||||
// Add expression, because the Instruction may be guarded by control flow
|
||||
// and the no-overflow bits may not be valid for the expression in any
|
||||
// context.
|
||||
SCEV::NoWrapFlags Wrap = GEP->isInBounds() ? SCEV::FlagNSW : SCEV::FlagAnyWrap;
|
||||
|
||||
const SCEV *TotalOffset = getConstant(IntPtrTy, 0);
|
||||
gep_type_iterator GTI = gep_type_begin(GEP);
|
||||
for (GetElementPtrInst::op_iterator I = llvm::next(GEP->op_begin()),
|
||||
@ -3217,9 +3217,7 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
||||
IndexS = getTruncateOrSignExtend(IndexS, IntPtrTy);
|
||||
|
||||
// Multiply the index by the element size to compute the element offset.
|
||||
const SCEV *LocalOffset = getMulExpr(IndexS, ElementSize,
|
||||
isInBounds ? SCEV::FlagNSW :
|
||||
SCEV::FlagAnyWrap);
|
||||
const SCEV *LocalOffset = getMulExpr(IndexS, ElementSize, Wrap);
|
||||
|
||||
// Add the element offset to the running total offset.
|
||||
TotalOffset = getAddExpr(TotalOffset, LocalOffset);
|
||||
@ -3230,8 +3228,7 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
||||
const SCEV *BaseS = getSCEV(Base);
|
||||
|
||||
// Add the total offset from all the GEP indices to the base.
|
||||
return getAddExpr(BaseS, TotalOffset,
|
||||
isInBounds ? SCEV::FlagNSW : SCEV::FlagAnyWrap);
|
||||
return getAddExpr(BaseS, TotalOffset, Wrap);
|
||||
}
|
||||
|
||||
/// GetMinTrailingZeros - Determine the minimum number of zero bits that S is
|
||||
|
Loading…
x
Reference in New Issue
Block a user