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

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>:

https://gcc.gnu.org/g:10478270fe0c39c59eb0f35d19356a63bdf3a2ad

commit r13-4687-g10478270fe0c39c59eb0f35d19356a63bdf3a2ad
Author: Martin Jambor <mjam...@suse.cz>
Date:   Wed Dec 14 00:33:06 2022 +0100

    ipa-sra: Treat REFERENCE_TYPES as always dereferencable

    C++ and especially Fortran pass data by references which are not
    pointers potentially pointing anywhere and so can be assumed to be
    safely dereferencable.  This patch teaches IPA-SRA to treat them as
    such and avoid the dance we do to prove that we can move loads from
    them to the caller.

    When we do not know that a dereference will happen all the time, we
    need a heuristics so that we do not force memory accesses that normally
    happen only rarely.  The patch simply uses the (possibly guessed)
    profile and checks whether the (expected) number of loads is at least
    half of function invocations invocations - the half is now
    configurable with a param as requested by Honza.

    gcc/ChangeLog:

    2022-12-13  Martin Jambor  <mjam...@suse.cz>

            PR ipa/103585
            * params.opt (ipa-sra-deref-prob-threshold): New parameter.
            * doc/invoke.texi (ipa-sra-deref-prob-threshold): Document it.
            * ipa-sra.cc (struct gensum_param_access): New field load_count.
            (struct gensum_param_desc): New field safe_ref, adjusted comments.
            (by_ref_count): Renamed to unsafe_by_ref_count, adjusted all uses.
            (dump_gensum_access): Dump the new field.
            (dump_gensum_param_descriptor): Likewise.
            (create_parameter_descriptors): Set safe_ref field, move setting
            by_ref forward.  Only increment unsafe_by_ref_count for unsafe
            by_ref parameters.
            (allocate_access): Initialize new field.
            (mark_param_dereference): Adjust indentation.  Only add data to
            bb_dereferences for unsafe by_ref parameters.
            (scan_expr_access): For loads, accumulate BB counts.
            (dereference_probable_p): New function.
            (check_gensum_access): Fix leading comment, add parameter FUN.
            Check cumulative counts of loads for safe by_ref accesses instead
            of dereferences.
            (process_scan_results): Do not propagate dereference distances for
            safe by_ref parameters.  Pass fun to check_gensum_access.  Safe
            by_ref params do not need the postdominance check.

    gcc/testsuite/ChangeLog:

    2022-11-11  Martin Jambor  <mjam...@suse.cz>

            * g++.dg/ipa/ipa-sra-5.C: New test

Reply via email to