public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110888] New: Missing optimization for trivial MATMUL cases, requires -fno-signed-zeros
@ 2023-08-03  7:06 rimvydas.jas at gmail dot com
  2023-08-03  7:11 ` [Bug fortran/110888] " rimvydas.jas at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rimvydas.jas at gmail dot com @ 2023-08-03  7:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110888
           Summary: Missing optimization for trivial MATMUL cases,
                    requires -fno-signed-zeros
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rimvydas.jas at gmail dot com
  Target Milestone: ---

$ cat foo.f90
subroutine foo(x,y,z)
  implicit none
  real(kind=selected_real_kind(9,99)) :: x(1), y(1,1), z(1)
  z = matmul(x,y)
end subroutine

$ gfortran -c -S -Wall -Wextra -O2 -fdump-tree-optimized foo.f90

The do loop get reduced in matmul intrinsic implementation, however redundant
accumulator store is not optimized out during PRE if
-ffast-math(-fno-signed-zeros) is not used:
   <bb 2> [local count: 536870912]:
   __builtin_memset (z_11(D), 0, 8);
-  _18 = (*z_11(D))[0];
   _19 = (*x_13(D))[0];
   _20 = (*y_14(D))[0];
   _21 = _19 * _20;
-  _22 = _18 + _21;
+  _22 = _21 + 0.0;
   (*z_11(D))[0] = _22;
   return;

Not sure if it is possible to mark accumulator expr as artificial so that
optimizers could ignore side effects by default, but luckily it is easily
avoidable in frontend itself.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-05  4:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03  7:06 [Bug fortran/110888] New: Missing optimization for trivial MATMUL cases, requires -fno-signed-zeros rimvydas.jas at gmail dot com
2023-08-03  7:11 ` [Bug fortran/110888] " rimvydas.jas at gmail dot com
2023-08-04  1:01 ` jvdelisle at gcc dot gnu.org
2023-08-04 15:38 ` [Bug middle-end/110888] " tkoenig at gcc dot gnu.org
2023-08-04 15:45 ` [Bug fortran/110888] " tkoenig at gcc dot gnu.org
2023-08-05  4:22 ` rimvydas.jas at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).