mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 06:33:21 +00:00
Just as its not safe to blindly transfer the nsw bit from an add
instruction to an add scev, it's not safe to blindly transfer the inbounds flag from a gep instruction to an nsw on the scev for the gep. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107117 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b22dc70a5c
commit
7a64257f94
@ -2763,7 +2763,11 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
|
|||||||
///
|
///
|
||||||
const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
||||||
|
|
||||||
bool InBounds = GEP->isInBounds();
|
// Don't 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.
|
||||||
|
|
||||||
const Type *IntPtrTy = getEffectiveSCEVType(GEP->getType());
|
const Type *IntPtrTy = getEffectiveSCEVType(GEP->getType());
|
||||||
Value *Base = GEP->getOperand(0);
|
Value *Base = GEP->getOperand(0);
|
||||||
// Don't attempt to analyze GEPs over unsized objects.
|
// Don't attempt to analyze GEPs over unsized objects.
|
||||||
@ -2781,7 +2785,7 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
|||||||
unsigned FieldNo = cast<ConstantInt>(Index)->getZExtValue();
|
unsigned FieldNo = cast<ConstantInt>(Index)->getZExtValue();
|
||||||
TotalOffset = getAddExpr(TotalOffset,
|
TotalOffset = getAddExpr(TotalOffset,
|
||||||
getOffsetOfExpr(STy, FieldNo),
|
getOffsetOfExpr(STy, FieldNo),
|
||||||
/*HasNUW=*/false, /*HasNSW=*/InBounds);
|
/*HasNUW=*/false, /*HasNSW=*/false);
|
||||||
} else {
|
} else {
|
||||||
// For an array, add the element offset, explicitly scaled.
|
// For an array, add the element offset, explicitly scaled.
|
||||||
const SCEV *LocalOffset = getSCEV(Index);
|
const SCEV *LocalOffset = getSCEV(Index);
|
||||||
@ -2789,13 +2793,13 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
|||||||
LocalOffset = getTruncateOrSignExtend(LocalOffset, IntPtrTy);
|
LocalOffset = getTruncateOrSignExtend(LocalOffset, IntPtrTy);
|
||||||
// Lower "inbounds" GEPs to NSW arithmetic.
|
// Lower "inbounds" GEPs to NSW arithmetic.
|
||||||
LocalOffset = getMulExpr(LocalOffset, getSizeOfExpr(*GTI),
|
LocalOffset = getMulExpr(LocalOffset, getSizeOfExpr(*GTI),
|
||||||
/*HasNUW=*/false, /*HasNSW=*/InBounds);
|
/*HasNUW=*/false, /*HasNSW=*/false);
|
||||||
TotalOffset = getAddExpr(TotalOffset, LocalOffset,
|
TotalOffset = getAddExpr(TotalOffset, LocalOffset,
|
||||||
/*HasNUW=*/false, /*HasNSW=*/InBounds);
|
/*HasNUW=*/false, /*HasNSW=*/false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getAddExpr(getSCEV(Base), TotalOffset,
|
return getAddExpr(getSCEV(Base), TotalOffset,
|
||||||
/*HasNUW=*/false, /*HasNSW=*/InBounds);
|
/*HasNUW=*/false, /*HasNSW=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetMinTrailingZeros - Determine the minimum number of zero bits that S is
|
/// GetMinTrailingZeros - Determine the minimum number of zero bits that S is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user