Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp @@ -2727,9 +2727,11 @@ } } + // x >> y <=u x // x udiv y <=u x. - if (LBO && match(LBO, m_UDiv(m_Specific(RHS), m_Value()))) { - // icmp pred (X /u Y), X + if (LBO && (match(LBO, m_LShr(m_Specific(RHS), m_Value())) || + match(LBO, m_UDiv(m_Specific(RHS), m_Value())))) { + // icmp pred (X op Y), X if (Pred == ICmpInst::ICMP_UGT) return getFalse(ITy); if (Pred == ICmpInst::ICMP_ULE) Index: llvm/trunk/test/Transforms/InstSimplify/compare.ll =================================================================== --- llvm/trunk/test/Transforms/InstSimplify/compare.ll +++ llvm/trunk/test/Transforms/InstSimplify/compare.ll @@ -397,6 +397,22 @@ ; CHECK: ret i1 true } +define i1 @lshr4(i32 %X, i32 %Y) { +; CHECK-LABEL: @lshr4( + %A = lshr i32 %X, %Y + %C = icmp ule i32 %A, %X + ret i1 %C +; CHECK: ret i1 true +} + +define i1 @lshr5(i32 %X, i32 %Y) { +; CHECK-LABEL: @lshr5( + %A = lshr i32 %X, %Y + %C = icmp ugt i32 %A, %X + ret i1 %C +; CHECK: ret i1 false +} + define i1 @ashr1(i32 %x) { ; CHECK-LABEL: @ashr1( %s = ashr i32 -1, %x