[llvm] [DAG] foldShiftToAvg - recognize sub(x, xor(y, -1)) >> 1 as avgceil[su] (#147946) (PR #156239)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 03:57:17 PDT 2025
================
@@ -16294,6 +16412,23 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
}
}
+ // trunc (avgceilu (sext (x), sext (y))) -> avgceils(x, y)
+ if (N0.getOpcode() == ISD::AVGCEILU) {
+ SDValue SExtX = N0.getOperand(0);
+ SDValue SExtY = N0.getOperand(1);
+ if ((SExtX.getOpcode() == ISD::SIGN_EXTEND &&
+ SExtY.getOpcode() == ISD::SIGN_EXTEND) ||
+ (SExtX.getOpcode() == ISD::SIGN_EXTEND_INREG &&
+ SExtY.getOpcode() == ISD::SIGN_EXTEND_INREG)) {
----------------
RKSimon wrote:
Not sure if SIGN_EXTEND_INREG will work?
https://github.com/llvm/llvm-project/pull/156239
More information about the llvm-commits
mailing list