[llvm] [DAGCombiner] Turn `(neg (max x, (neg x)))` into `(min x, (neg x))` (PR #120666)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 01:28:35 PST 2024
================
@@ -3949,6 +3949,20 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
if (SDValue Result = TLI.expandABS(N1.getNode(), DAG, true))
return Result;
+ // Similar to the previous rule, but this time targeting an expanded abs.
+ // (sub 0, (max X, (sub 0, X))) --> (min X, (sub 0, X))
----------------
jayfoad wrote:
Could also do the converse:
```
(sub 0, (min X, (sub 0, X))) --> (max X, (sub 0, X))
```
but I don't know if there's a real need for it.
https://github.com/llvm/llvm-project/pull/120666
More information about the llvm-commits
mailing list