mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
Use a sign-extend instead of a zero-extend when promoting a
trip count value when the original loop iteration condition is signed and the canonical induction variable won't undergo signed overflow. This isn't required for correctness; it just preserves more information about original loop iteration values. Add a getTruncateOrSignExtend method to ScalarEvolution, following getTruncateOrZeroExtend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64918 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -755,6 +755,21 @@ SCEVHandle ScalarEvolution::getTruncateOrZeroExtend(const SCEVHandle &V,
|
||||
return getZeroExtendExpr(V, Ty);
|
||||
}
|
||||
|
||||
/// getTruncateOrSignExtend - Return a SCEV corresponding to a conversion
|
||||
/// of the input value to the specified type. If the type must be
|
||||
/// extended, it is sign extended.
|
||||
SCEVHandle ScalarEvolution::getTruncateOrSignExtend(const SCEVHandle &V,
|
||||
const Type *Ty) {
|
||||
const Type *SrcTy = V->getType();
|
||||
assert(SrcTy->isInteger() && Ty->isInteger() &&
|
||||
"Cannot truncate or sign extend with non-integer arguments!");
|
||||
if (SrcTy->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
|
||||
return V; // No conversion
|
||||
if (SrcTy->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits())
|
||||
return getTruncateExpr(V, Ty);
|
||||
return getSignExtendExpr(V, Ty);
|
||||
}
|
||||
|
||||
// get - Get a canonical add expression, or something simpler if possible.
|
||||
SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
||||
assert(!Ops.empty() && "Cannot get empty add!");
|
||||
|
Reference in New Issue
Block a user