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

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 08:29:35 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.
----------------
RKSimon wrote:

Yes, that's another one that is probably worth it (not sure if we have an existing test case for that, although the avg tests are more extensive than you'd expect.....). These are pretty generic folds, but I can move this into X86 if people prefer?

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


More information about the llvm-commits mailing list