diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index ac79031d7632b..45fd6238dc866 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3481,7 +3481,8 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, SmallVector IndicesRHS(GRHS->idx_begin(), GRHS->idx_end()); Constant *NewRHS = ConstantExpr::getGetElementPtr( GLHS->getSourceElementType(), Null, IndicesRHS); - return ConstantExpr::getICmp(Pred, NewLHS, NewRHS); + Constant *NewICmp = ConstantExpr::getICmp(Pred, NewLHS, NewRHS); + return ConstantFoldConstant(NewICmp, Q.DL); } } } diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll index c4e791fc6695e..3dfdaf2ecf2f1 100644 --- a/llvm/test/Transforms/InstSimplify/compare.ll +++ b/llvm/test/Transforms/InstSimplify/compare.ll @@ -301,7 +301,7 @@ define i1 @gep17() { define i1 @gep_same_base_constant_indices(i8* %a) { ; CHECK-LABEL: @gep_same_base_constant_indices( -; CHECK-NEXT: ret i1 icmp slt (i8* getelementptr (i8, i8* null, i64 1), i8* getelementptr (i8, i8* null, i64 10)) +; CHECK-NEXT: ret i1 true ; %arrayidx1 = getelementptr inbounds i8, i8* %a, i64 1 %arrayidx2 = getelementptr inbounds i8, i8* %a, i64 10