fortran: Optimize access to span-addressed dummy arguments.
Reduces overhead for dummy arguments in Fortran by folding spacing into strides, enabling loop vectorization.
This change optimizes Fortran dummy arguments that are addressed via their descriptor’s span. Previously, this indirection prevented loop vectorization and incurred copy-in/copy-out overhead. The fix folds the element spacing into the strides, allowing direct addressing and enabling optimizations like vectorization. It also refines checks for subobject references.
In Details
To address PR126964, this commit modifies how TARGET assumed shape/rank dummy arguments are accessed. Instead of dereferencing through the span of the descriptor for every element (making strides symbolic and preventing vectorization), the spacing is now folded into the strides on entry. This allows constant element strides and enables loop vectorization. It also refactors is_subref_array to correctly handle these optimized dummies, preventing unnecessary copies.
- dummy argument
- In Fortran, a variable that receives a value from a procedure call. Dummy arguments can have various properties like assumed shape or rank.
- span-addressed
- Describes an array or array element accessed indirectly through a descriptor that contains both a base address and stride information.
- loop vectorization
- An optimization technique where a loop's operations are converted to use single instructions that operate on multiple data elements simultaneously (SIMD).
- descriptor
- A data structure containing information about an array, such as its base address, shape, and element stride.
- stride
- The distance in memory between consecutive elements of an array.