[PATCH] D14369: [ValueTracking] De-pessimize isImpliedCondition around unsigned compares

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 11:03:34 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL252332: [ValueTracking] De-pessimize isImpliedCondition around unsigned compares (authored by sanjoy).

Changed prior to commit:
  http://reviews.llvm.org/D14369?vs=39313&id=39566#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14369

Files:
  llvm/trunk/lib/Analysis/ValueTracking.cpp
  llvm/trunk/test/Transforms/InstSimplify/implies.ll

Index: llvm/trunk/test/Transforms/InstSimplify/implies.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/implies.ll
+++ llvm/trunk/test/Transforms/InstSimplify/implies.ll
@@ -65,7 +65,7 @@
   ret i1 %res
 }
 
-; i +_{nuw} C_{>0} <u L ==> i <u L
+; i +_{nuw} C <u L ==> i <u L
 define i1 @test4(i32 %length.i, i32 %i) {
 ; CHECK-LABEL: @test4
 ; CHECK: ret i1 true
@@ -116,6 +116,17 @@
   ret i1 %res
 }
 
+; i +_{nuw} C <s L ==> i < L, even if C is negative
+define i1 @test9(i32 %length.i, i32 %i) {
+; CHECK-LABEL: @test9(
+; CHECK: ret i1 true
+  %iplus1 = add nuw i32 %i, -100
+  %var29 = icmp ult i32 %i, %length.i
+  %var30 = icmp ult i32 %iplus1, %length.i
+  %res = icmp ule i1 %var30, %var29
+  ret i1 %res
+}
+
 ; X >=(s) Y == X ==> Y (i1 1 becomes -1 for reasoning)
 define i1 @test_sge(i32 %length.i, i32 %i) {
 ; CHECK-LABEL: @test_sge
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -4109,12 +4109,12 @@
   case CmpInst::ICMP_ULE: {
     ConstantInt *CI;
 
-    // LHS u<  LHS +_{nuw} C   if C > 0
-    // LHS u<= LHS +_{nuw} C   if C >= 0
+    // LHS u<  LHS +_{nuw} C   if C != 0
+    // LHS u<= LHS +_{nuw} C
     if (match(RHS, m_NUWAdd(m_Specific(LHS), m_ConstantInt(CI)))) {
       if (Pred == CmpInst::ICMP_ULT)
-        return CI->getValue().isStrictlyPositive();
-      return !CI->isNegative();
+        return !CI->isZero();
+      return true;
     }
     return false;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14369.39566.patch
Type: text/x-patch
Size: 1630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151106/1f99f419/attachment.bin>


More information about the llvm-commits mailing list