Fortran array slice zeroing optimized with memset.
Fortran array slice assignments to zero now use `memset` for improved performance.
This change optimizes the zero assignment for contiguous Fortran array slices by utilizing the memset function. Previously, a regression caused issues where gfc_is_simply_contiguous incorrectly returned false for slices that were otherwise recognized as contiguous. This update not only fixes that bug by improving the gfc_is_simply_contiguous check but also refactors gfc_trans_zero_assign to leverage memset for potentially faster zeroing operations on array slices.
In Details
This patch addresses two related issues in GFortran's Fortran frontend. First, it corrects gfc_is_simply_contiguous to return true for array sections where one extent is one, resolving a regression that incorrectly flagged such slices as non-contiguous. Second, it refactors gfc_trans_zero_assign to use memset for zeroing contiguous array slices, improving performance. The copyable_slice_p helper function is introduced to determine if a slice can be safely copied, considering aspects like reallocatable expressions and corank, and is used by gfc_trans_assignment to invoke `gfc_trans_z…
- memset
- A standard C library function that fills a block of memory with a specified byte value. It is often highly optimized for performance.
- array slice
- A portion of an array selected by specifying ranges for one or more dimensions. For example,
A(:, 1:5)selects all elements of the first dimension and elements 1 through 5 of the second dimension. - contiguous
- In Fortran, an array or array section is contiguous if its elements are stored in adjacent memory locations in the order they are defined.
- Gfortran
- GNU Fortran Compiler, the Fortran frontend for GCC.