InstCombine: Removing the base from the address calculation is only safe when the...
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 20 Feb 2012 18:45:10 +0000 (18:45 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 20 Feb 2012 18:45:10 +0000 (18:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150978 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCompares.cpp

index 5a91c7b97021c2bf100b69a0613253cdb3b2fcf5..b62f6e204969ae594a3ae0f820700575ea240f3a 100644 (file)
@@ -610,7 +610,7 @@ Instruction *InstCombiner::FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
       // If we're comparing GEPs with two base pointers that only differ in type
       // and both GEPs have only constant indices or just one use, then fold
       // the compare with the adjusted indices.
-      if (TD &&
+      if (TD && GEPLHS->isInBounds() && GEPRHS->isInBounds() &&
           (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) &&
           (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) &&
           PtrBase->stripPointerCasts() ==