[llvm] [DAGCombiner] Turn `(neg (max x, (neg x)))` into `(min x, (neg x))` (PR #120666)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 20 10:53: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))
----------------
mshockwave wrote:

I think it's fine to add it in this patch. It's done now.

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


More information about the llvm-commits mailing list