stripAndComputeConstantOffsets is only called on pointers; check this
authorDan Gohman <dan433584@gmail.com>
Thu, 31 Jan 2013 00:12:20 +0000 (00:12 +0000)
committerDan Gohman <dan433584@gmail.com>
Thu, 31 Jan 2013 00:12:20 +0000 (00:12 +0000)
with an assert instead of failing and requiring callers to check for failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173998 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InstructionSimplify.cpp

index d97e226c3ae9f8b54cdc5dbe443fa27cb7a2dce1..bc51457406614b81b0806324299f09622cad132a 100644 (file)
@@ -665,8 +665,7 @@ Value *llvm::SimplifyAddInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
 /// no constant offsets applied.
 static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
                                                 Value *&V) {
-  if (!V->getType()->isPointerTy())
-    return 0;
+  assert(V->getType()->isPointerTy());
 
   unsigned IntPtrWidth = TD.getPointerSizeInBits();
   APInt Offset = APInt::getNullValue(IntPtrWidth);
@@ -701,11 +700,7 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
 static Constant *computePointerDifference(const DataLayout &TD,
                                           Value *LHS, Value *RHS) {
   Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
-  if (!LHSOffset)
-    return 0;
   Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
-  if (!RHSOffset)
-    return 0;
 
   // If LHS and RHS are not related via constant offsets to the same base
   // value, there is nothing we can do here.
@@ -1710,11 +1705,7 @@ static Constant *computePointerICmp(const DataLayout &TD,
   }
 
   Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
-  if (!LHSOffset)
-    return 0;
   Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
-  if (!RHSOffset)
-    return 0;
 
   // If LHS and RHS are not related via constant offsets to the same base
   // value, there is nothing we can do here.