[llvm] [ConstraintElimination] Extend unsigned-to-signed fact transfer (PR #66173)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 04:04:42 PDT 2023


================
@@ -748,11 +749,22 @@ void ConstraintInfo::transferToOtherSystem(
   default:
     break;
   case CmpInst::ICMP_ULT:
-    //  If B is a signed positive constant, A >=s 0 and A <s B.
+  case CmpInst::ICMP_ULE:
+    //  If B is a signed positive constant, A >=s 0 and A <s (or <=s) B.
     if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0))) {
       addFact(CmpInst::ICMP_SGE, A, ConstantInt::get(B->getType(), 0), NumIn,
               NumOut, DFSInStack);
-      addFact(CmpInst::ICMP_SLT, A, B, NumIn, NumOut, DFSInStack);
+      addFact(CmpInst::getSignedPredicate(Pred), A, B, NumIn, NumOut,
+              DFSInStack);
+    }
+    break;
+  case CmpInst::ICMP_UGE:
+  case CmpInst::ICMP_UGT:
+    //  If A is a signed positive constant, B >=s 0 and A >s (or >=s) B.
----------------
fhahn wrote:

I think adding a `then` would make the sentence easier to parse.
```suggestion
    //  If A is a signed positive constant, then B >=s 0 and A >s (or >=s) B.
```

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


More information about the llvm-commits mailing list