[llvm] [RISCV][WIP] Optimize sum of absolute differences pattern. (PR #82722)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 12:43:02 PST 2024


================
@@ -13176,6 +13176,61 @@ static SDValue performXORCombine(SDNode *N, SelectionDAG &DAG,
   return combineSelectAndUseCommutative(N, DAG, /*AllOnes*/ false, Subtarget);
 }
 
+// Look for (abs (sub (zext X), (zext Y))).
+// Rewrite as (zext (sub (zext (max X, Y), (min X, Y)))) if the user is an add
----------------
preames wrote:

(This is mostly a response to myself)

Here's the alive2 proof for the transformation in this patch:

https://alive2.llvm.org/ce/z/XoCBZ5

Note the need for noundef on the source parameters.  Alternatively, we could use freeze in the target.

Here's my proposed variant:

https://alive2.llvm.org/ce/z/f7MdJe

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


More information about the llvm-commits mailing list