Hello Thomas,

This patch looks OK to me, applies cleanly, passes regression testing
and even does the intended job :-) OK for mainline.

You might take a look at the related PR40598, which I last had a stab
at a couple of months ago. I caused all manner of regressions and so
gave up. I am unassigning myself.

Mit besten Gruessen

Paul


On Sat, 14 Nov 2026 at 09:50, Thomas Koenig <[email protected]> wrote:
>
> Hello world,
>
> This patch was motivated by the observation that the middle and back
> ends currently generate inefficient code for what our scalarizers
> generate for copies of contiguous array slices.  It modifies the
> contitions for issuing __builtin_memcpy so that variable-sized arrays
> and array slices are handled.  While I looked at the code, I found
> that generating temporaries could be avoided in some cases by using
> memmove, so I added that as well.
>
> Regression-tested. OK for trunk?
>
> Best regards
>
>         Thomas
>
>
> gcc/fortran/ChangeLog:
>
>         PR fortran/128542
>         * trans-expr.cc (gfc_build_compare_string): Correct comment.
>         (gfc_build_memcpy_call): If use_memmove is true, call
>         __builtin_memmove.
>         (gfc_trans_array_copy): Also handle array slices and arrays
>         whose extents are not known at compile-time, including bounds
>         checking.
>         (copyable_slice_p): New function.
>         (gfc_trans_assignment): Use copyable_slice_p and do not check
>         dependency before calling gfc_trans_array_copy.
>         * trans.h (gfc_build_memcpy_call): Add optional argument
>         use_memmove.
>
> gcc/testsuite/ChangeLog:
>
>         PR fortran/128542
>         * gfortran.dg/array_temporaries_1.f90: One less temporary
>         created. Add check for memmove.
>         * gfortran.dg/dependency_28.f90: Likewise.
>         * gfortran.dg/elemental_dependency_1.f90:  Remove variable
>         names from original dump scan. Add memcpy calls.
>         * gfortran.dg/array_memcpy_6.f90: New test.

Reply via email to