Move variable under condition where it is used
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 12 Sep 2013 01:07:58 +0000 (01:07 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 12 Sep 2013 01:07:58 +0000 (01:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190567 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp

index 03199629cb2ad73dd1bd6e25963fd93fb6e9fc74..9b7999c4e3f8aa90418d6734ff15950050675cc0 100644 (file)
@@ -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.