[Bug fortran/97063] [ MATMUL intrinsic] The value of result is wrong when vector (step size is negative) * matrix
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 22 19:42:32 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97063
--- Comment #4 from anlauf at gcc dot gnu.org ---
Having looked at the tree-dump, I am not sure if it is a FE or a library issue.
I appears that the negative stride miscalculates the base or offset of
the array probably by one:
program p
implicit none
integer :: i, j
real, dimension(6) :: arr1 = [(i,i=0,5)]
real, dimension(6,10) :: arr2 = reshape ([(((i+j),i=0,5),j=0,9)],[6,10])
real, dimension(10) :: arr3, arr6
real, dimension(3) :: arr4
arr4 = arr1(5:1:-2)
write(*,*) "--arr6--:"
arr6 = matmul (arr4 , arr2(5:1:-2, :))
write(*,'(10F6.1)') arr6
arr4 = arr1(6:2:-2)
write(*,*) "--arr6-- (with arr1 off by one):"
arr6 = matmul (arr4 , arr2(5:1:-2, :))
write(*,'(10F6.1)') arr6
arr3 = matmul (arr1(5:1:-2), arr2(5:1:-2, :))
write(*,*) "--arr3--:"
write(*,'(10F6.1)') arr3
end program
This prints:
--arr6--:
20.0 26.0 32.0 38.0 44.0 50.0 56.0 62.0 68.0 74.0
--arr6-- (with arr1 off by one):
26.0 35.0 44.0 53.0 62.0 71.0 80.0 89.0 98.0 107.0
--arr3--:
26.0 35.0 44.0 53.0 62.0 71.0 80.0 89.0 98.0 107.0
More information about the Gcc-bugs
mailing list