PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and

zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jay Foad
2010-12-07 08:25:19 +00:00
parent 0ea112f104
commit 40f8f6264d
25 changed files with 219 additions and 251 deletions

View File

@ -206,14 +206,14 @@ static Value *GetLinearExpression(Value *V, APInt &Scale, APInt &Offset,
Value *CastOp = cast<CastInst>(V)->getOperand(0);
unsigned OldWidth = Scale.getBitWidth();
unsigned SmallWidth = CastOp->getType()->getPrimitiveSizeInBits();
Scale.trunc(SmallWidth);
Offset.trunc(SmallWidth);
Scale = Scale.trunc(SmallWidth);
Offset = Offset.trunc(SmallWidth);
Extension = isa<SExtInst>(V) ? EK_SignExt : EK_ZeroExt;
Value *Result = GetLinearExpression(CastOp, Scale, Offset, Extension,
TD, Depth+1);
Scale.zext(OldWidth);
Offset.zext(OldWidth);
Scale = Scale.zext(OldWidth);
Offset = Offset.zext(OldWidth);
return Result;
}