[llvm] [DAG] Fold mismatched widened avg idioms to narrow form (#147946) (PR #163366)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 23 04:13:06 PDT 2025
================
@@ -16482,10 +16482,30 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
DAG, DL);
}
break;
- case ISD::AVGFLOORS:
- case ISD::AVGFLOORU:
case ISD::AVGCEILS:
case ISD::AVGCEILU:
+ // trunc (avgceilu (sext (x), sext (y))) -> avgceils(x, y)
+ // trunc (avgceils (zext (x), zext (y))) -> avgceilu(x, y)
+ if (N0.hasOneUse()) {
+ SDValue Op0 = N0.getOperand(0);
+ SDValue Op1 = N0.getOperand(1);
+ if (N0.getOpcode() == ISD::AVGCEILU) {
+ if (TLI.isOperationLegalOrCustom(ISD::AVGCEILS, VT) &&
----------------
laurenmchin wrote:
great, thanks for confirming. i'll keep the fold scoped as is (SEXT/ZEXT only)
https://github.com/llvm/llvm-project/pull/163366
More information about the llvm-commits
mailing list