[llvm-commits] [llvm] r144121 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/compare.ll

Eli Friedman eli.friedman at gmail.com
Tue Nov 8 13:08:03 PST 2011


Author: efriedma
Date: Tue Nov  8 15:08:02 2011
New Revision: 144121

URL: http://llvm.org/viewvc/llvm-project?rev=144121&view=rev
Log:
Fix code to match comment.  Fixes PR11340, a regression from r143209.


Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp
    llvm/trunk/test/Transforms/InstSimplify/compare.ll

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=144121&r1=144120&r2=144121&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Tue Nov  8 15:08:02 2011
@@ -1612,7 +1612,7 @@
       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);

Modified: llvm/trunk/test/Transforms/InstSimplify/compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/compare.ll?rev=144121&r1=144120&r2=144121&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/compare.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/compare.ll Tue Nov  8 15:08:02 2011
@@ -342,6 +342,16 @@
 ; 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





More information about the llvm-commits mailing list