forked from OSchip/llvm-project
InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds.
llvm-svn: 150978
This commit is contained in:
parent
66562a4a54
commit
ac8ecc4e7e
|
@ -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
|
// 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
|
// and both GEPs have only constant indices or just one use, then fold
|
||||||
// the compare with the adjusted indices.
|
// the compare with the adjusted indices.
|
||||||
if (TD &&
|
if (TD && GEPLHS->isInBounds() && GEPRHS->isInBounds() &&
|
||||||
(GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) &&
|
(GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) &&
|
||||||
(GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) &&
|
(GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) &&
|
||||||
PtrBase->stripPointerCasts() ==
|
PtrBase->stripPointerCasts() ==
|
||||||
|
|
Loading…
Reference in New Issue