Index: lib/Analysis/InstructionSimplify.cpp =================================================================== --- lib/Analysis/InstructionSimplify.cpp +++ lib/Analysis/InstructionSimplify.cpp @@ -2857,6 +2857,17 @@ return getTrue(ITy); } + // x >=u x >> y + // x >=u x udiv y. + if (RBO && (match(RBO, m_LShr(m_Specific(LHS), m_Value())) || + match(RBO, m_UDiv(m_Specific(LHS), m_Value())))) { + // icmp pred X, (X op Y) + if (Pred == ICmpInst::ICMP_ULT) + return getFalse(ITy); + if (Pred == ICmpInst::ICMP_UGE) + return getTrue(ITy); + } + // handle: // CI2 << X == CI // CI2 << X != CI Index: test/Transforms/InstSimplify/compare.ll =================================================================== --- test/Transforms/InstSimplify/compare.ll +++ test/Transforms/InstSimplify/compare.ll @@ -409,6 +409,14 @@ ; CHECK: ret i1 false } +define i1 @lshr6(i32 %X, i32 %Y) { +; CHECK-LABEL: @lshr6( + %A = lshr i32 %X, %Y + %C = icmp ult i32 %X, %A + ret i1 %C +; CHECK: ret i1 false +} + define i1 @ashr1(i32 %x) { ; CHECK-LABEL: @ashr1( %s = ashr i32 -1, %x