[llvm] [WIP][DAG] Add legalization handling for AVGCEIL/AVGFLOOR nodes (PR #92096)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 09:34:07 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.
----------------
goldsteinn wrote:
Unless there is certainty that no other target can benefit, imo its written generically enough to keep here.
I.e the general pattern: `if(NotLegal(A) && IsLegal(B) && MayTransform(A, B)) { return B; }` is sensible as a generic combine, even if the motivation was one particular target.
https://github.com/llvm/llvm-project/pull/92096
More information about the llvm-commits
mailing list