[InstSimplify] add nuw %x, C2 must be at least C2
[oota-llvm.git] / lib / Analysis / InstructionSimplify.cpp
index ae9d6664fb86f992f46588e276ef738321ea74d2..b6d4c02a9eb1473b378b08eced57c7475d6343e2 100644 (file)
@@ -2360,6 +2360,9 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
     } else if (match(LHS, m_And(m_Value(), m_ConstantInt(CI2)))) {
       // 'and x, CI2' produces [0, CI2].
       Upper = CI2->getValue() + 1;
+    } else if (match(LHS, m_NUWAdd(m_Value(), m_ConstantInt(CI2)))) {
+      // 'add nuw x, CI2' produces [CI2, UINT_MAX].
+      Lower = CI2->getValue();
     }
     if (Lower != Upper) {
       ConstantRange LHS_CR = ConstantRange(Lower, Upper);