<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64173>64173</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Poor performance of code with transfer intrinsic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
performance,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kiranchandramohan
</td>
</tr>
</table>
<pre>
Code with transfer intrinsic is much slower with flang compared to gfortran.
**Source**
```
program test
implicit none
Integer*8 :: mysum = 0
real :: r
integer :: i,j,k
r = 1.2
Do k = 1, 10
Do j = 1, 2156
Do i = 1, 2156
call sum4(mysum, r)
End Do
End Do
End Do
write(*,*)'checksum =', mysum
end program test
subroutine sum4 (mysum, r)
implicit none
Integer*8, intent (inout) :: mysum
Real, intent (in) :: r
Integer*1 i4(4)
i4 = transfer(r, i4)
mysum = ((((mysum + i4(1)) + i4(2)) + i4(3)) + i4(4))
Return
end subroutine sum4
```
**Run time**
```
$ ./bin/flang-new -O3 transfer.f90
$ time ./a.out
checksum = -11388423200
real 0m1.552s
user 0m1.548s
sys 0m0.004s
$ gfortran -O3 transfer.f90
$ time ./a.out
checksum = -11388423200
real 0m0.019s
user 0m0.015s
sys 0m0.004s
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2PozgQ_TXmUgqCwgQ4cOhJNtKedtX7CwwYcDfYkT-21f9-ZQMNSe_MaSTLiV9VPT-eXWbGiEFyXpP8B8mvEXN2VLp-F5rJdmSy02xWI5NRo7rP-qI6Dh_CjmA1k6bnGoS0WkgjWhAGZteOYCb1wfWS1k9MDtCq-c4078AqGHqlfXFMkitJXtYZ_fhHOd3y5f-Kn5N1hOVdq0GzGSw3dkEAxHyfRCssSCX5Cv4pLR-4JvhSAsleSPYC86dxM5DsCslWqTmbtrD-oltKN1wQvLwRvLx_FQWONMYVuCp4XyCCF0i_yMFH3vYIpvl5j4Wo-HkUoGXTBMbNlGAZtPs0TbA6pv0hO7iqHXlcP6w-tLCcYBncvYS5Ili0I2_fV2cIFn6TZbdQxWUH3z1fZuMarZwVkgeZ8DOdD-cDG3o4IV_gXZfWcwipnCVYPZzbWvXK2fScfUjV38lTEN5AetRDg-3b_SVY6sB5yNnvSjBsHSuKPxbONBhY7QA-A9kzQBdgU_LKrdNyd_rJ0f_tgGO7vDoJVsy_ahiCFGKCt8YbdQvNeJL8A05_ZV8OxH11yPaEoYTFytntvI7XBE5pmpUlxQyTB1Whn5I5jfMczQI5w7W_mAGl5YqaTwMLmsRJQs2--_Y4fBMIv0_htnFafRPp0fwg8kng5m3U1VlXZRWLeJ2eq4SWFCmNxprSvOF525cVpUnD-7zvipJ3RdEWRV5lfSRqTDBLCizSMi-Qxi1mHe_PRXqmmJfnnNCEz0xM8TT9O8dKD5EwxvH6TNMiiybW8MmEpxrxznWv9MykfzIxNDWGE_ar_Brp2nOcGjcYQpNJGGt2VivsFN78W6jIr_C3UhoOnKB6aH_x3EdOT_Vo7d349sMbwdsg7OiauFUzwZvfav053bV6460leAtfYwjewgf9FwAA___3os2A">