From 9cb059fdcc03e2144fa9aac0bfbb49c0d5d7efe2 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 23 Aug 2019 18:27:57 +0000 Subject: Fix a bug in just submitted rL369789 Started implementing the vector case and realized the scalar case hadn't handled the GEP producing a different type than the base correctly. It's entertaining seeing what slips through review when we're focused on the 'hard' parts. :( Also adding an extra vector test as it happened to be in workspace and wasn't worth separating. llvm-svn: 369795 --- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') 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(RHS), + Base->getType())); } else if (GEPOperator *GEPRHS = dyn_cast(RHS)) { // If the base pointers are different, but the indices are the same, just // compare the base pointer. -- cgit v1.2.3