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

--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <[email protected]>:

https://gcc.gnu.org/g:b960a57e1b00390c2ca9ff1406b72232d379a322

commit r16-7504-gb960a57e1b00390c2ca9ff1406b72232d379a322
Author: Andrew Pinski <[email protected]>
Date:   Thu Feb 12 20:36:33 2026 -0800

    forwprop: Add copy prop for aggregates into a return [PR95825]

    I didn't implement this before today as I had not see any code
    where this would make a difference. I noticed while looking into
    regressions an uninitialized warning that shows up only with
    -fsanitize=address. This because SRA causes some extra total
    scalaization when using -fsanitize=address. Which in turn exposes
    an uninitialized warning. This fixes the uninitialized warning
    by doing a simple copy prop into the return statement.

    That is if we have:
    ```
      D.3407 = D.3418;
      return D.3407;
    ```

    turn it into:
    ```
      D.3407 = D.3418;
      return D.3418;
    ```

    This forces SRA not to do total scalarization on D.3418 and allows for
better code
    too.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/95825

    gcc/ChangeLog:

            * tree-ssa-forwprop.cc (optimize_agr_copyprop_return): New
function.
            (optimize_agr_copyprop): Call optimize_agr_copyprop_return
            for return statements.

    gcc/testsuite/ChangeLog:

            * g++.dg/warn/uninit-pr95825-1.C: New test.
            * gcc.dg/tree-ssa/copy-prop-aggregate-return-1.c: New test.

    Signed-off-by: Andrew Pinski <[email protected]>

Reply via email to