diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-09-12 01:07:58 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-09-12 01:07:58 +0000 |
commit | 180df81c8f2a30abda712a0a99149c6b9a4241aa (patch) | |
tree | 3b8ded2be8a89fc8f96d68df8fffe2f374a26671 /lib/Analysis/ConstantFolding.cpp | |
parent | b95237f10cf718c63b153e362b3b5b548ce50698 (diff) | |
download | llvm-180df81c8f2a30abda712a0a99149c6b9a4241aa.tar.gz llvm-180df81c8f2a30abda712a0a99149c6b9a4241aa.tar.bz2 llvm-180df81c8f2a30abda712a0a99149c6b9a4241aa.tar.xz |
Move variable under condition where it is used
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190567 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 03199629cb..9b7999c4e3 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -586,12 +586,13 @@ static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0, if (Opc == Instruction::Sub && DL) { GlobalValue *GV1, *GV2; unsigned PtrSize = DL->getPointerSizeInBits(); - unsigned OpSize = DL->getTypeSizeInBits(Op0->getType()); APInt Offs1(PtrSize, 0), Offs2(PtrSize, 0); if (IsConstantOffsetFromGlobal(Op0, GV1, Offs1, *DL)) if (IsConstantOffsetFromGlobal(Op1, GV2, Offs2, *DL) && GV1 == GV2) { + unsigned OpSize = DL->getTypeSizeInBits(Op0->getType()); + // (&GV+C1) - (&GV+C2) -> C1-C2, pointer arithmetic cannot overflow. // PtrToInt may change the bitwidth so we have convert to the right size // first. |