Strange behavior of `ifort`

@zaikunzhang . Attn: @greenrongreen ,

As to the -fp:fast vs other -fp compiler options with IFORT, here’s a simpler variant to also consider:

   real, parameter :: foo = 1.2409463E+22, bar = -4.4971432E+21, baz = -3.4729614E+20 
   real :: x(6)
   x = [ foo, bar, baz, bar, baz, foo ] ; x = x / maxval(x)
   print *, abs( x - x([6,4,5,2,3,1]) ) <= 0
   print *, x
   print *, x([6,4,5,2,3,1])
   print "(*(b0,1x))", x(1), x(6)
   print "(*(b0,1x))", x(2), x(4)
   print "(*(b0,1x))", x(3), x(5)
end 
  1. With the default i.e., -fp:fast option:
C:\temp>ifort /standard-semantics p.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.33.31630.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:p.exe
-subsystem:console
p.obj

C:\temp>p.exe
 F T F T F F
 0.9999999 -0.3623963 -2.7986394E-02 -0.3623963 -2.7986396E-02
 1.000000
 1.000000 -0.3623963 -2.7986396E-02 -0.3623963 -2.7986394E-02
 0.9999999
111111011111111111111111111111 111111100000000000000000000000
10111110101110011000110000000001 10111110101110011000110000000001
10111100111001010100001110111001 10111100111001010100001110111010

C:\temp>
  1. With the -fp:precise option,
C:\temp>ifort /standard-semantics /fp:precise p.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.33.31630.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:p.exe
-subsystem:console
p.obj

C:\temp>p.exe
 T T T T T T
 1.000000 -0.3623963 -2.7986396E-02 -0.3623963 -2.7986396E-02
 1.000000
 1.000000 -0.3623963 -2.7986396E-02 -0.3623963 -2.7986396E-02
 1.000000
111111100000000000000000000000 111111100000000000000000000000
10111110101110011000110000000001 10111110101110011000110000000001
10111100111001010100001110111010 10111100111001010100001110111010

C:\temp>

@zaikunzhang , you can also review at Compiler Explorer some of the aggressive actions coming into play with -fp:fast with the arrays and vector subscripts or such situations de facto with the TRANSPOSE intrinsic.

1 Like