From 7781ae5be570940178295f6f808215089a3fe411 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 8 Nov 2011 21:08:02 +0000 Subject: Fix code to match comment. Fixes PR11340, a regression from r143209. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144121 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/InstructionSimplify.cpp | 2 +- test/Transforms/InstSimplify/compare.ll | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index c141632..2f41f72 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -1612,7 +1612,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, Lower = (-Upper) + 1; } else if (match(LHS, m_UDiv(m_ConstantInt(CI2), m_Value()))) { // 'udiv CI2, x' produces [0, CI2]. - Upper = CI2->getValue(); + Upper = CI2->getValue() + 1; } else if (match(LHS, m_UDiv(m_Value(), m_ConstantInt(CI2)))) { // 'udiv x, CI2' produces [0, UINT_MAX / CI2]. APInt NegOne = APInt::getAllOnesValue(Width); diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll index db5e72f..9f3dffe 100644 --- a/test/Transforms/InstSimplify/compare.ll +++ b/test/Transforms/InstSimplify/compare.ll @@ -342,6 +342,16 @@ define i1 @udiv5(i32 %X) { ; CHECK: ret i1 false } +; PR11340 +define i1 @udiv6(i32 %X) nounwind { +; CHECK: @udiv6 + %A = udiv i32 1, %X + %C = icmp eq i32 %A, 0 + ret i1 %C +; CHECK: ret i1 %C +} + + define i1 @sdiv1(i32 %X) { ; CHECK: @sdiv1 %A = sdiv i32 %X, 1000000 -- cgit v1.1