diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2239,9 +2239,11 @@ // those conditions rather than checking them. This is difficult because of // undef/poison (PR34838). if (IsAShr) { - if (Pred == CmpInst::ICMP_SLT || (Pred == CmpInst::ICMP_SGT && IsExact)) { + if (Pred == CmpInst::ICMP_SLT || (Pred == CmpInst::ICMP_SGT && IsExact) || + (Pred == CmpInst::ICMP_UGT && IsExact)) { // icmp slt (ashr X, ShAmtC), C --> icmp slt X, (C << ShAmtC) // icmp sgt (ashr exact X, ShAmtC), C --> icmp sgt X, (C << ShAmtC) + // icmp ugt (ashr exact X, ShAmtC), C --> icmp ugt X, (C << ShAmtC) APInt ShiftedC = C.shl(ShAmtVal); if (ShiftedC.ashr(ShAmtVal) == C) return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); diff --git a/llvm/test/Transforms/InstCombine/icmp-shr-lt-gt.ll b/llvm/test/Transforms/InstCombine/icmp-shr-lt-gt.ll --- a/llvm/test/Transforms/InstCombine/icmp-shr-lt-gt.ll +++ b/llvm/test/Transforms/InstCombine/icmp-shr-lt-gt.ll @@ -2216,6 +2216,15 @@ ret i1 %c } +define i1 @lashrugt_00_00_exact(i8 %x) { +; CHECK-LABEL: @lashrugt_00_00_exact( +; CHECK-NEXT: %c = icmp ugt i8 %x, 80 +; + %s = ashr exact i8 %x, 3 + %c = icmp ugt i8 %s, 10 + ret i1 %c +} + define i1 @lshrult_01_00_exact(i4 %x) { ; CHECK-LABEL: @lshrult_01_00_exact( ; CHECK-NEXT: ret i1 false