[llvm] [InstCombine] Fold select(X >s 0, 0, -X) | smax(X, 0) to abs(X) (PR #165200)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 08:35:47 PDT 2025


================
@@ -3997,6 +3997,20 @@ static Value *foldOrUnsignedUMulOverflowICmp(BinaryOperator &I,
   return nullptr;
 }
 
+// Fold select(X >s 0, 0, -X) | smax(X, 0) --> abs(X)
----------------
dtcxzyw wrote:

```suggestion
/// Fold select(X >s 0, 0, -X) | smax(X, 0) --> abs(X)
```

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


More information about the llvm-commits mailing list