http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57785
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-07-02
CC| |burnus at gcc dot gnu.org,
| |franke.daniel at gmail dot com
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The following change
print *, 'z.z= ',DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0),
(1.0, 4.0) /))
print *, 'z.z= ',SUM( CONJG((/ (1.0, 2.0), (2.0, 3.0) /))*(/ (1.0, 1.0),
(1.0, 4.0) /))
print *, 'z.z= ',SUM( (/ (1.0, 2.0), (2.0, 3.0) /)*(/ (1.0, 1.0),
(1.0, 4.0) /))
end
gives
z.z= ( -11.000000 , 14.000000 )
z.z= ( 17.000000 , 4.0000000 )
z.z= ( -11.000000 , 14.000000 )
i.e., DOT_PRODUCT applied to constant vectors does not implement CONJG of the
first vector. If I am not mistaken, the computation is done in
compute_dot_product as
case BT_INTEGER:
case BT_REAL:
case BT_COMPLEX:
result = gfc_add (result,
gfc_multiply (gfc_copy_expr (a),
gfc_copy_expr (b)));
break;
default:
gcc_unreachable();
in fortran/simplify.c (if I comment the line
case BT_COMPLEX:
the compilation reaches the following gcc_unreachable();).
This is right for MATMUL, but not for DOT_PRODUCT for which compute_dot_product
is called from gfc_simplify_dot_product as
return compute_dot_product (vector_a, 1, 0, vector_b, 1, 0);
The code has been introduced in revision 148243.
I think the fix should be applied in gfc_simplify_dot_product by applying
gfc_simplify_conjg to vector_a if it complex.