[llvm] [ConstraintElim] Use isKnownNonNegative for signed->unsigned transfer. (PR #72879)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 00:45:29 PST 2023


================
@@ -786,7 +786,8 @@ void ConstraintInfo::transferToOtherSystem(
   case CmpInst::ICMP_ULT:
   case CmpInst::ICMP_ULE:
     //  If B is a signed positive constant, then A >=s 0 and A <s (or <=s) B.
-    if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0))) {
+    if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0)) ||
+        isKnownNonNegative(B, DL, /*Depth=*/MaxAnalysisRecursionDepth - 1)) {
----------------
nikic wrote:

```suggestion
    if (IsNonNegative(B)) {
```
Extract this into a lambda?

https://github.com/llvm/llvm-project/pull/72879


More information about the llvm-commits mailing list