Index: llvm/lib/Analysis/ValueTracking.cpp =================================================================== --- llvm/lib/Analysis/ValueTracking.cpp +++ llvm/lib/Analysis/ValueTracking.cpp @@ -7939,6 +7939,10 @@ if (match(RHS, m_NUWAdd(m_Specific(LHS), m_APInt(C)))) return true; + // (RHS >> X) u<= RHS for any X + if (match(LHS, m_LShr(m_Specific(RHS), m_Value()))) + return true; + // Match A to (X +_{nuw} CA) and B to (X +_{nuw} CB) auto MatchNUWAddsToSameValue = [&](const Value *A, const Value *B, const Value *&X, @@ -7993,6 +7997,13 @@ 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 @@ -273,9 +273,8 @@ ; CHECK-LABEL: @test_shift( ; CHECK-NEXT: [[LSHR:%.*]] = lshr i64 [[X:%.*]], [[SHIFT:%.*]] ; CHECK-NEXT: [[ICMP1:%.*]] = icmp ugt i64 [[LSHR]], [[Y:%.*]] -; CHECK-NEXT: [[ICMP2:%.*]] = icmp ugt i64 [[X]], [[Y]] ; CHECK-NEXT: call void @llvm.assume(i1 [[ICMP1]]) -; CHECK-NEXT: ret i1 [[ICMP2]] +; CHECK-NEXT: ret i1 true ; %lshr = lshr i64 %x, %shift %icmp1 = icmp ugt i64 %lshr, %y