[Bug fortran/56342] New: MATMUL with PARAMETER: Simplification usually doesn't work
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 15 14:28:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56342
Bug #: 56342
Summary: MATMUL with PARAMETER: Simplification usually doesn't
work
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
Depends on: 56318
This is a follow up to PR 56318, reported by Alberto Luaces at
http://gcc.gnu.org/ml/fortran/2013-02/msg00074.html
The wrong-code issue has been fixed, however, it was noted there that MATMUL
with parameters is not get optimized.
Simplified test case:
!------------------------------------
integer, parameter :: A(3,2) = reshape([1,2,3,4,5,6],[3,2])
integer, parameter :: B(2,3) = reshape([1,1,1,1,1,1],[2,3])
integer, parameter :: m1 = 1
print '(3i3)', matmul(A,B) ! Does not get optimized
print '(3i3)', m1*matmul(A,B) ! Is optimized
end
!------------------------------------
(See the other PR for the original test case - and gfortran.dg/matmul_9.f90;
they all use the multiplication - which lead to simplification and hit a now
fixed wrong-code bug.)
The "m1*" is crucial. When gfc_simplify_matmul is called initially, it returns
NULL as "is_constant_array_expr (matrix_a)" is false.
The "m1*" causes a re-evaluation of the RHS expression, namely in
gfc_simplify_expr:
for (ap = p->value.function.actual; ap; ap = ap->next)
if (gfc_simplify_expr (ap->expr, type) == FAILURE)
That converts an EXPR_VARIABLE with flavor FL_PARAMETER into an EXPR_ARRAY,
which can then be processed by calling gfc_simplify_matmul.
It seems as if one has to run "gfc_simplify_expr" – the question is whether
that shouldn't then also be done for other intrinsics?
More information about the Gcc-bugs
mailing list