diff options
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 2bc21292b13..4e161d612cf 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -914,7 +914,10 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS, // In general, we're allowed to make values less poison (i.e. remove // sources of full UB), so in this case, we just select between the two // non-poison cases (1 and 4 above). - return new ICmpInst(Cond, GEPLHS->getPointerOperand(), RHS); + auto *Base = GEPLHS->getPointerOperand(); + return new ICmpInst(Cond, Base, + ConstantExpr::getBitCast(cast<Constant>(RHS), + Base->getType())); } else if (GEPOperator *GEPRHS = dyn_cast<GEPOperator>(RHS)) { // If the base pointers are different, but the indices are the same, just // compare the base pointer. |