[llvm] [WIP][DAG] Add legalization handling for AVGCEIL/AVGFLOOR nodes (PR #92096)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 08:18:31 PDT 2024


================
@@ -5234,6 +5234,20 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
   if (N0 == N1 && Level >= AfterLegalizeTypes)
     return N0;
 
+  // Fold avgflooru(x,c) -> avgceilu(x,c-1)
+  // iff c > 0 and avgflooru isn't legal/custom but avgceilu is.
----------------
jayfoad wrote:

> Its purely to get around x86 regressions (which only has avgceilu)

Ack. Is it worth legalizing the signed versions to the unsigned ones by flipping the sign bit of both inputs and the result?

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


More information about the llvm-commits mailing list