https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112418

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>:

https://gcc.gnu.org/g:8d6d6d537fdc754a429b08091422c307188f3c82

commit r15-4503-g8d6d6d537fdc754a429b08091422c307188f3c82
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Wed Sep 4 12:11:43 2024 -0700

    phiopt: do factor_out_conditional_operation for all phis [PR112418]

    Sometimes factor_out_conditional_operation can factor out
    an operation that causes a phi node to become the same element.
    Other times, we want to factor out a binary operator because
    it can improve code generation, an example is PR 110015 (openjpeg).

    Note this includes a heuristic to decide if factoring out the operation
    is profitable or not. It can be expanded to include a better live range
    extend detector. Right now it has a simple one where if it is live on a
    dominating path, it is considered a live or if there are a small # of
    assign statements (defaults to 5), then it does not extend the live range
    too much.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/112418

    gcc/ChangeLog:

            * tree-ssa-phiopt.cc (is_factor_profitable): New function.
            (factor_out_conditional_operation): Add merge argument. Remove
            arg0/arg1 arguments. Return bool instead of the new phi.
            Early return for virtual ops. Call is_factor_profitable to
            check if the factoring would be profitable.
            (pass_phiopt::execute): Call factor_out_conditional_operation
            on all phis instead of just singleton phi.
            * doc/invoke.texi (--param phiopt-factor-max-stmts-live=):
Document.
            * params.opt (--param=phiopt-factor-max-stmts-live=): New opt.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/factor_op_phi-1.c: New test.
            * gcc.dg/tree-ssa/factor_op_phi-2.c: New test.
            * gcc.dg/tree-ssa/factor_op_phi-3.c: New test.
            * gcc.dg/tree-ssa/factor_op_phi-4.c: New test.

    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Reply via email to