[llvm] r190567 - Move variable under condition where it is used
Matt Arsenault
Matthew.Arsenault at amd.com
Wed Sep 11 18:07:58 PDT 2013
Author: arsenm
Date: Wed Sep 11 20:07:58 2013
New Revision: 190567
URL: http://llvm.org/viewvc/llvm-project?rev=190567&view=rev
Log:
Move variable under condition where it is used
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=190567&r1=190566&r2=190567&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed Sep 11 20:07:58 2013
@@ -586,12 +586,13 @@ static Constant *SymbolicallyEvaluateBin
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.
More information about the llvm-commits
mailing list