diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 59e5f5ad0a4f..7612356cac29 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3753,6 +3753,11 @@ Instruction *foldICmpXNegX(ICmpInst &I) { NewRHS = Constant::getNullValue(X->getType()); break; + case ICmpInst::ICMP_UGE: + NewPred = ICmpInst::ICMP_SGE; + NewRHS = Constant::getNullValue(X->getType()); + break; + case ICmpInst::ICMP_EQ: case ICmpInst::ICMP_NE: NewPred = Pred; diff --git a/llvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll b/llvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll index c2cbeab9ed91..0b2fb2a17f42 100644 --- a/llvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll +++ b/llvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll @@ -81,8 +81,7 @@ define i1 @t4(i8 %x) { define i1 @t5(i8 %x) { ; CHECK-LABEL: @t5( -; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] -; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NEG_X]], [[X]] +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1 ; CHECK-NEXT: ret i1 [[CMP]] ; %neg_x = sub nsw i8 0, %x