Index: llvm/lib/Analysis/ValueTracking.cpp =================================================================== --- llvm/lib/Analysis/ValueTracking.cpp +++ llvm/lib/Analysis/ValueTracking.cpp @@ -8144,12 +8144,26 @@ return true; return std::nullopt; + case CmpInst::ICMP_SGT: + case CmpInst::ICMP_SGE: + if (isTruePredicate(CmpInst::ICMP_SLE, ALHS, BLHS, DL, Depth) && + isTruePredicate(CmpInst::ICMP_SLE, BRHS, ARHS, DL, Depth)) + return true; + return std::nullopt; + case CmpInst::ICMP_ULT: case CmpInst::ICMP_ULE: if (isTruePredicate(CmpInst::ICMP_ULE, BLHS, ALHS, DL, Depth) && isTruePredicate(CmpInst::ICMP_ULE, ARHS, BRHS, DL, Depth)) return true; return std::nullopt; + + case CmpInst::ICMP_UGT: + case CmpInst::ICMP_UGE: + if (isTruePredicate(CmpInst::ICMP_ULE, ALHS, BLHS, DL, Depth) && + isTruePredicate(CmpInst::ICMP_ULE, BRHS, ARHS, DL, Depth)) + return true; + return std::nullopt; } } Index: llvm/test/Transforms/InstSimplify/implies.ll =================================================================== --- llvm/test/Transforms/InstSimplify/implies.ll +++ llvm/test/Transforms/InstSimplify/implies.ll @@ -270,11 +270,7 @@ define i1 @test_sgt(i32 %length.i, i32 %i) { ; CHECK-LABEL: @test_sgt( -; CHECK-NEXT: [[IPLUS1:%.*]] = add nsw i32 [[I:%.*]], 1 -; CHECK-NEXT: [[VAR29:%.*]] = icmp sgt i32 [[LENGTH_I:%.*]], [[I]] -; CHECK-NEXT: [[VAR30:%.*]] = icmp sgt i32 [[LENGTH_I]], [[IPLUS1]] -; CHECK-NEXT: [[RES:%.*]] = icmp ule i1 [[VAR30]], [[VAR29]] -; CHECK-NEXT: ret i1 [[RES]] +; CHECK-NEXT: ret i1 true ; %iplus1 = add nsw i32 %i, 1 %var29 = icmp sgt i32 %length.i, %i