[llvm] [DAG] foldShiftToAvg - recognize sub(x, xor(y, -1)) >> 1 as avgceil[su] (#147946) (PR #156239)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 11:16:48 PDT 2025
================
@@ -16294,6 +16412,23 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
}
}
+ // trunc (avgceilu (sext (x), sext (y))) -> avgceils(x, y)
----------------
laurenmchin wrote:
> Please can you move this down to the switch statement below (handle avgceilu first and [[fallthrough]] to share the common code with the other avg/abd opcodes.
>
> You also need to create an alive2 test for this.
>
> Ideally we should add this fold first in a separate PR - you need to create some suitable test coverage and create a separate PR.
thanks, will do. i’ll work on moving the logic under the switch and submit a separate PR with test coverage + an alive2 proof for the fold. will follow up soon.
https://github.com/llvm/llvm-project/pull/156239
More information about the llvm-commits
mailing list