[patch, fortran] Create temporary variables for matmul
Thomas Koenig
tkoenig@netcologne.de
Sun May 7 10:18:00 GMT 2017
Hello world,
the attached patch goes one step further in matmul inlinding.
It converts statements like
r = dot_product(matmul(a2,v1),v2)
into
tmp = matmul(a2,v1)
r = dot_product(tmp,v2)
to enable inlining of matmul (but only if inlining
is active, of course).
In order to detect multiple uses of matmul, this is run
several times. I did this because, with the current
implementation, create_var can fail if -fno-realloc-lhs
is specified. This is also not optimal, but that's a bug
for another day, and I don't see any drawbacks in
code generation for this (the extra basic blocks will
be removed).
The actual overhead in the case of non-constant bounds should
be small to non-existent, this only replaces one type of
temporary with another.
I had to adjust some test cases which counted things to use
the library version.
Regression-tested. OK for trunk?
Regards
Thomas
P.S: Next on the agenda is to better handle the left-over combinations
for Matmul, and to create temporaries for dependencies and
function evaluations in the arguments that we currently do not
handle.
2017-05-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/79930
* frontend-passes.c (matmul_to_var_expr): New function,
add prototype.
(matmul_to_var_code): Likewise.
(optimize_namespace): Use them from gfc_code_walker.
2017-05-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/79930
* gfortran.dg/inline_transpose_1.f90: Add
-finline-matmul-limit=0 to options.
* gfortran.dg/matmul_5.f90: Likewise.
* gfortran.dg/vect/vect-8.f90: Likewise.
* gfortran.dg/inline_matmul_14.f90: New test.
* gfortran.dg/inline_matmul_15.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p5.diff
Type: text/x-patch
Size: 4461 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20170507/269b0404/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inline_matmul_14.f90
Type: text/x-fortran
Size: 3520 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20170507/269b0404/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inline_matmul_15.f90
Type: text/x-fortran
Size: 452 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20170507/269b0404/attachment-0002.bin>
More information about the Fortran
mailing list