[llvm] [InstSimplify] Simplify the select with integer comparison relationship (PR #66668)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 03:39:41 PDT 2023


================
@@ -8285,6 +8285,15 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
   if (areMatchingOperands(L0, L1, R0, R1, AreSwappedOps))
     return isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps);
 
+  if (RPred == ICmpInst::ICMP_SLT) {
+    Value *X;
+    Value *Y;
+    // x-y+1 is positive when x >= y or non-positive when x < y
----------------
nikic wrote:

```suggestion
    // x -nsw y is non-negative when x >= y or negative when x < y
```
You match only the sub here, not an extra +1, so the comment should match that.

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


More information about the llvm-commits mailing list