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 | bed5bf2e90d14faba5b59c22bd240bf592b48dfb (patch) | |
tree | c2963dd7290564d789b4456524ec3fdcf769c9d5 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | a9e7c7abdc8f6d0dbb7ef861b3df22d51c969891 (diff) | |
download | bcm5719-llvm-bed5bf2e90d14faba5b59c22bd240bf592b48dfb.tar.gz bcm5719-llvm-bed5bf2e90d14faba5b59c22bd240bf592b48dfb.zip |
Move variable under condition where it is used
llvm-svn: 190567
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 03199629cb2..9b7999c4e3f 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/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. |