https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99355

            Bug ID: 99355
           Summary: -freal-X-real-Y -freal-Z-real-X promotes Z to Y
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickpapior at gmail dot com
  Target Milestone: ---

Created attachment 50291
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50291&action=edit
Same as code snippet

I came about this in LAPACK which allows compiling in quad precision.

However, mixed precision algorithms will no longer be mixed precision since
*everything* gets promoted.

See this code snippet (and attached as well):

program test
  real :: r1
  real*4:: r2
  real(4) :: r3
  real(selected_real_kind(p=6)) :: r4

  double precision :: d1
  real*8 :: d2
  real(8) :: d3
  real(kind(1.d0)) :: d4
  real(selected_real_kind(p=15)) :: d5

  print '(tr3,a10,10(tr1,i2))', 'single', kind(r1), kind(r2), kind(r3),
kind(r4)
  print '(tr3,a10,10(tr1,i2))', 'double', kind(d1), kind(d2), kind(d3),
kind(d4), kind(d5)
end program test


Here listed with 4 different flag combinations:

#FLAGS = 
       single  4  4  4  4
       double  8  8  8  8  8
#FLAGS = -freal-4-real-8
       single  8  8  8  8
       double  8  8  8  8  8
#FLAGS = -freal-8-real-16
       single  4  4  4  4
       double 16 16 16 16 16
#FLAGS = -freal-8-real-16 -freal-4-real-8 (order doesn't matter)
       single  8 16 16 16
       double 16 16 16 16 16

The first 3 flag combinations works as intended.
The last one behaves bad.

I would have expected 8->16 and 4->8 (without double promotion).

Reply via email to