[llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Benjamin Kramer
benny.kra at googlemail.com
Mon Feb 20 10:45:10 PST 2012
Author: d0k
Date: Mon Feb 20 12:45:10 2012
New Revision: 150978
URL: http://llvm.org/viewvc/llvm-project?rev=150978&view=rev
Log:
InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=150978&r1=150977&r2=150978&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 12:45:10 2012
@@ -610,7 +610,7 @@
// 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() ==
More information about the llvm-commits
mailing list