Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ishft not optimized in 2017.2

TimP
Honored Contributor III
207 Views

For a long time I used the ugly replacement of i/2 (positive integer) by ishft(i,-1).  If a compiler didn't optimize /2 with shifts, it could be very slow.  Now the new compiler no longer optimizes ishft.  I verified this so far for Haswell client and MIC KNC.

Context (netlib vector "seq function" benchmark):

  forall(i= 2:n) a(i)= b(i)+c(i/2)*d(i)

There is a C analog.  I used to write (unsigned int)i/2 so as to assure optimization, but the 2017.0.2 compiler optimizes only without the cast.  In gcc there is still a small advantage to the cast, although gfortran doesn't care much whether I use /2 or ishft.

0 Kudos
1 Reply
Kevin_D_Intel
Employee
207 Views

Thanks Tim. We'll investigate.

0 Kudos
Reply