SATURDAY, AUGUST 1, 2026
gcc/fortran Performance Win
Inline MATMUL(TRANSPOSE(A),B) for rank 1 B.
Optimized inlining of matrix multiplication involving a transposed matrix and a rank-1 matrix.
This commit enables the inlining of MATMUL(TRANSPOSE(A),B) when B is a rank-1 matrix. While loop ordering presents challenges due to dependencies, GCC’s unrolling capabilities allow for better code generation, especially for smaller matrices. The change modifies frontend passes to handle this specific matrix case.
In Details
The Fortran frontend's inline_matmul_assign function is enhanced to recognize and optimize the A2TB1 case (matrix A transposed, matrix B rank 1). This involves updating frontend-passes.cc to include this new case and adjusting reallocation logic in matmul_lhs_realloc to support the optimization.
For Context
- MATMUL
- A Fortran intrinsic function for matrix multiplication.
- TRANSPOSE
- A Fortran intrinsic function that returns the transpose of an array.
- rank 1
- In Fortran, an array with one dimension (a vector).