Hello, I noticed this is noticably slower with ifort 14.0.0 than with gfortran. Is there anything to make the result run faster?
use iso_fortran_env real(real32) :: x32 integer(int64) :: t1, t2, trate call system_clock(count_rate=trate) call system_clock(count=t1) do i=1,int(2E9) x32 = swapb32(x32) end do call system_clock(count=t2) print *,x32,"time",real(t2-t1)/trate contains function swapb32(x) result(res) real(real32) :: res real(real32),intent(in) :: x character(4) :: bytes integer(int32) :: t bytes = transfer(x,bytes) !equivalence very slightly faster, but problematic. t = ichar(bytes(4:4),int64) t = ior( ishftc(ichar(bytes(3:3),int32),8), t ) t = ior( ishftc(ichar(bytes(2:2),int32),16), t ) t = ior( ishftc(ichar(bytes(1:1),int32),24), t ) res = transfer(t, res) end function end
> gfortran-4.9 -Ofast bitperf.f90 > ./a.out 0.00000000 time 5.00823069 > ifort -fast bitperf.f90 ipo: remark #11001: performing single-file optimizations ipo: remark #11006: generating object file /tmp/ipo_ifort0hhp0O.o > ./a.out 0.0000000E+00 time 13.35413