optimization bug in gfortran 6.3?
James Spencer
james.s.spencer@gmail.com
Sun May 14 16:42:00 GMT 2017
Hi,
Sorry in advance if this isn't the appropriate forum but I am confused
with behaviour I see with gcc 6.2 and 6.3 compared to 5.2 and 7.1. I
haven't been able to cut this down to a minimal test case but the
critical lines are lines 794-797 in
https://github.com/hande-qmc/hande/blob/master/src/energy_evaluation.F90#L794.
With gcc 6.3-O3 (similar behaviour with gcc 6.2 and other optimization
levels), -fdump-tree-optimized gives for this region:
<bb 10>:
_64 = &excitation_8(D)->from_orb[1];
_65 = &excitation_8(D)->from_orb[0];
ij_sym_66 = cross_product_basis_read_in (sys_15(D), _65, _64);
_67 = &excitation_8(D)->to_orb[1];
_68 = &excitation_8(D)->to_orb[0];
ab_sym_69 = cross_product_basis_read_in (sys_15(D), _68, _67);
if (ij_sym_66 == ab_sym_69)
goto <bb 11>;
else
goto <bb 12> (<L23>);
<bb 11>:
_70 = &excitation_8(D)->perm;
*hmatel_6(D) = slater_condon2_mol_excit (sys_15(D), _65, _64, _68,
_67, _70);
_72 = *estimators_10(D).proj_energy;
_73 = *pop.0_5[0];
_74 = _73 * 0.0;
_75 = _72 + _74;
*estimators_10(D).proj_energy = _75;
I am not familiar with the syntax given here but it seems that rather
than accumulating hmatel%r*pop(1), 0.0*pop(1) is instead accumulated.
Given slater_condon2_mol_excit is not a compile-time constant, this
looks like an optimization bug to me. (A debug build behaves as
expected.)
With the same optimization settings on gcc 7.1, -fdump-tree-optimized gives
<bb 10> [9.42%]:
_47 = &excitation_64(D)->from_orb[1];
_48 = &excitation_64(D)->from_orb[0];
ij_sym_66 = cross_product_basis_read_in (sys_65(D), _48, _47);
_49 = &excitation_64(D)->to_orb[1];
_50 = &excitation_64(D)->to_orb[0];
ab_sym_67 = cross_product_basis_read_in (sys_65(D), _50, _49);
if (ij_sym_66 == ab_sym_67)
goto <bb 11>; [37.68%]
else
goto <bb 12> (<L25>); [62.32%]
<bb 11> [3.55%]:
_51 = &excitation_64(D)->perm;
*hmatel_62(D) = slater_condon2_mol_excit (sys_65(D), _48, _47, _50,
_49, _51);
_52 = *estimators_69(D).proj_energy;
_53 = *hmatel_62(D).r;
_54 = *pop.0_61[0];
_55 = _53 * _54;
_56 = _52 + _55;
*estimators_69(D).proj_energy = _56;
(The same output for gfortran 5.2 looks similar.)
Here the accumulation is being performed as I would expect .
I tried to find a bug report for this in the bug tracker but failed.
Some questions:
1. Is this indeed a (known) bug?
2. If so, where was it fixed between gfortran 6.3 and 7.1? When was it
introduced?
3. If so, can the fix be backported to the 6 release series?
Thanks,
James Spencer
More information about the Fortran
mailing list