public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
@ 2021-05-26 18:42 gabrielle.hugo at cern dot ch
  2021-05-26 19:25 ` [Bug fortran/100778] [11 Regression] " anlauf at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: gabrielle.hugo at cern dot ch @ 2021-05-26 18:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100778
           Summary: Get SIGFPE on simple test with -fpe-trap=invalid and
                    SLP vectorization ON, with gfortran 11.1.0 on x86_64
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabrielle.hugo at cern dot ch
  Target Milestone: ---

Hello,

Updating gfortran from 10.3.0 to 11.1.0 leads to SIGFPE in a Fortran 77 project
(all things else equal).

The issue can actually be isolated and reproduced on x86_64 with the equivalent
simple test.f [1]: it runs smoothly when compiled with gfortran 10.3.0, and
leads to SIGFPE with gfortran 11.1.0.

To reproduce:
gfortran -O3 -Wall -Wextra -g -ffpe-trap=invalid test.f -o test
./test

The FPE is thrown from `x = x / norm` (while the branch should not have been
entered).

The issue disappears if additionally compiling with -fno-tree-slp-vectorize, or
if placing a printout in between `x = x / norm` and ` y = y / norm`.
The issue does not appear on ARM (tested on Apple M1).

Thanks in advance


[1] test.f:

      program test
      implicit none  

      double precision input(2)
      input(1) = 0.D+00
      input(2) = 0.D+00

      call normalize(input)

      end


      subroutine normalize(input)
      implicit none

      double precision input(2)
      double precision x, y, norm

      common / coordinates / x, y
      save / coordinates /

      x = input(1)
      y = input(2)
      norm = sqrt(x**2 + y**2)

      if (norm .gt. 1.D+00) then
         x = x / norm
         y = y / norm
         write (*, *) 'Normalized x and y.'
      end if

      write (*, *) 'Ended as expected.' 

      end

[2] gcc versions:

gcc version 10.3.0 (GCC)
Configured with:
/build/dkonst/gcc-clang/build/contrib/gcc-10.3.0/src/gcc/10.3.0/configure
--prefix=/build/dkonst/gcc-clang/lcgcmake-install/gcc/10.3.0/x86_64-centos7
-with-system-zlib --disable-multilib --enable-languages=all --with-gnu-ld
--with-gnu-as
Thread model: posix
Supported LTO compression algorithms: zlib

gcc version 11.1.0 (GCC)
Target: x86_64-pc-linux-gnu
Configured with:
/build/dkonst/gcc-clang-2/build/contrib/gcc-11.1.0/src/gcc/11.1.0/configure
--prefix=/build/dkonst/gcc-clang-2/lcgcmake-install/gcc/11.1.0/x86_64-centos7
-with-system-zlib --disable-multilib --enable-languages=all --with-gnu-ld
--with-gnu-as
Thread model: posix
Supported LTO compression algorithms: zlib

Tested on Centos7 and Fedora33.

[3] objdump -S test
gfortran 10.3.0 case:

      x = input(1)
  4011d9:       f2 0f 10 0f             movsd  (%rdi),%xmm1
      y = input(2)
  4011dd:       f2 0f 10 57 08          movsd  0x8(%rdi),%xmm2
      x = input(1)
  4011e2:       66 0f 10 27             movupd (%rdi),%xmm4
      norm = sqrt(x**2 + y**2)
  4011e6:       66 0f 28 c1             movapd %xmm1,%xmm0
  4011ea:       66 0f 28 da             movapd %xmm2,%xmm3
  4011ee:       f2 0f 59 c1             mulsd  %xmm1,%xmm0
      x = input(1)
  4011f2:       0f 29 25 77 2e 00 00    movaps %xmm4,0x2e77(%rip)        #
404070 <coordinates_>
      norm = sqrt(x**2 + y**2)
  4011f9:       f2 0f 59 da             mulsd  %xmm2,%xmm3
  4011fd:       f2 0f 58 c3             addsd  %xmm3,%xmm0
  401201:       f2 0f 51 c0             sqrtsd %xmm0,%xmm0

      if (norm .gt. 1.D+00) then
  401205:       66 0f 2f 05 53 0e 00    comisd 0xe53(%rip),%xmm0        #
402060 <options.2.0+0x20>
  40120c:       00 
  40120d:       77 51                   ja     401260 <normalize_+0x90>
  40120f:       48 8b 1d 52 0e 00 00    mov    0xe52(%rip),%rbx        # 402068
<options.2.0+0x28>
  401216:       48 89 e5                mov    %rsp,%rbp
         x = x / norm
         y = y / norm
         write (*, *) 'Normalized x and y.'
      end if

gfortran 11.1.0 case:
   x = input(1)
  4011d9:       66 0f 10 0f             movupd (%rdi),%xmm1
  4011dd:       66 0f 28 d9             movapd %xmm1,%xmm3
  4011e1:       66 0f 28 c1             movapd %xmm1,%xmm0
  4011e5:       0f 29 0d 84 2e 00 00    movaps %xmm1,0x2e84(%rip)        #
404070 <coordinates_>
      y = input(2)
      norm = sqrt(x**2 + y**2)
  4011ec:       f2 0f 59 c1             mulsd  %xmm1,%xmm0
  4011f0:       66 0f 15 db             unpckhpd %xmm3,%xmm3
  4011f4:       66 0f 28 d3             movapd %xmm3,%xmm2
  4011f8:       f2 0f 59 d3             mulsd  %xmm3,%xmm2
  4011fc:       f2 0f 58 c2             addsd  %xmm2,%xmm0
  401200:       f2 0f 51 c0             sqrtsd %xmm0,%xmm0

      if (norm .gt. 1.D+00) then
  401204:       66 0f 2f 05 54 0e 00    comisd 0xe54(%rip),%xmm0        #
402060 <options.2.0+0x20>
  40120b:       00 
         x = x / norm
  40120c:       66 0f 28 d0             movapd %xmm0,%xmm2
  401210:       66 0f 14 d2             unpcklpd %xmm2,%xmm2
  401214:       66 0f 5e ca             divpd  %xmm2,%xmm1
      if (norm .gt. 1.D+00) then
  401218:       77 4e                   ja     401268 <normalize_+0x98>
  40121a:       48 8b 1d 47 0e 00 00    mov    0xe47(%rip),%rbx        # 402068
<options.2.0+0x28>
  401221:       48 89 e5                mov    %rsp,%rbp
         y = y / norm
         write (*, *) 'Normalized x and y.'
      end if

Here, divpd is executed before ja.

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

* [Bug fortran/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
@ 2021-05-26 19:25 ` anlauf at gcc dot gnu.org
  2021-05-26 19:39 ` [Bug tree-optimization/100778] " anlauf at gcc dot gnu.org
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-05-26 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.1.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |10.3.0, 12.0
           Keywords|                            |wrong-code
            Summary|Get SIGFPE on simple test   |[11 Regression] Get SIGFPE
                   |with -fpe-trap=invalid and  |on simple test with
                   |SLP vectorization ON, with  |-fpe-trap=invalid and SLP
                   |gfortran 11.1.0 on x86_64   |vectorization ON, with
                   |                            |gfortran 11.1.0 on x86_64
   Last reconfirmed|                            |2021-05-26
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed for 11.1, but mainline (12-trunk) seems fine (again?).
Comparing the assembler code for both, there seems to be a lot
going on ...

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
  2021-05-26 19:25 ` [Bug fortran/100778] [11 Regression] " anlauf at gcc dot gnu.org
@ 2021-05-26 19:39 ` anlauf at gcc dot gnu.org
  2021-05-28 10:28 ` rguenth at gcc dot gnu.org
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-05-26 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |tree-optimization

--- Comment #2 from anlauf at gcc dot gnu.org ---
Changing component to tree-optimization for inspection by experts.

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
  2021-05-26 19:25 ` [Bug fortran/100778] [11 Regression] " anlauf at gcc dot gnu.org
  2021-05-26 19:39 ` [Bug tree-optimization/100778] " anlauf at gcc dot gnu.org
@ 2021-05-28 10:28 ` rguenth at gcc dot gnu.org
  2021-05-28 10:30 ` [Bug tree-optimization/100778] [11/12 " rguenth at gcc dot gnu.org
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-28 10:28 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.2
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  It's SLP vectorization placing the vectorized division outside of
the if:

   <bb 2> [local count: 1073741824]:
+  vectp.9_32 = &(*input_8(D))[0];
+  vect__1.10_33 = MEM <vector(2) real(kind=8)> [(real(kind=8) *)vectp.9_32];
+  _35 = BIT_FIELD_REF <vect__1.10_33, 64, 64>;
+  _34 = BIT_FIELD_REF <vect__1.10_33, 64, 0>;
   _1 = (*input_8(D))[0];
-  coordinates.x = _1;
   _2 = (*input_8(D))[1];
-  coordinates.y = _2;
-  _11 = _1 * _1;
-  _12 = _2 * _2;
+  MEM <vector(2) real(kind=8)> [(real(kind=8) *)&coordinates] = vect__1.10_33;
+  _11 = _34 * _34;
+  _12 = _35 * _35;
   _3 = _11 + _12;
   norm_13 = __builtin_sqrt (_3);
+  _37 = {norm_13, norm_13};
+  vect__4.13_38 = vect__1.10_33 / _37;
   if (norm_13 > 1.0e+0)
     goto <bb 3>; [41.48%]
   else
@@ -34,13 +64,11 @@

   <bb 3> [local count: 445388112]:
   _4 = _1 / norm_13;
-  coordinates.x = _4;
   _5 = _2 / norm_13;
-  coordinates.y = _5;
+  MEM <vector(2) real(kind=8)> [(real(kind=8) *)&coordinates] = vect__4.13_38;

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

* [Bug tree-optimization/100778] [11/12 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (2 preceding siblings ...)
  2021-05-28 10:28 ` rguenth at gcc dot gnu.org
@ 2021-05-28 10:30 ` rguenth at gcc dot gnu.org
  2021-05-28 13:18 ` cvs-commit at gcc dot gnu.org
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-28 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|12.0                        |
            Summary|[11 Regression] Get SIGFPE  |[11/12 Regression] Get
                   |on simple test with         |SIGFPE on simple test with
                   |-fpe-trap=invalid and SLP   |-fpe-trap=invalid and SLP
                   |vectorization ON, with      |vectorization ON, with
                   |gfortran 11.1.0 on x86_64   |gfortran 11.1.0 on x86_64

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The same happens on trunk for me but there we sink the stmt back into the
if because we've added another sinking pass.

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

* [Bug tree-optimization/100778] [11/12 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (3 preceding siblings ...)
  2021-05-28 10:30 ` [Bug tree-optimization/100778] [11/12 " rguenth at gcc dot gnu.org
@ 2021-05-28 13:18 ` cvs-commit at gcc dot gnu.org
  2021-05-28 13:19 ` rguenth at gcc dot gnu.org
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-28 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:f7a07f5a5d8065e7f11133dd1f4ad3510ab2195b

commit r12-1115-gf7a07f5a5d8065e7f11133dd1f4ad3510ab2195b
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 28 14:26:06 2021 +0200

    tree-optimization/100778 - avoid cross-BB vectorization of trapping op

    This avoids vectorizing a possibly trapping operation when lanes
    are handled in different BBs.  I spotted this when working on the
    originally reported issue in PR100778.

    2021-05-28  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/100778
            * tree-vect-slp.c (vect_build_slp_tree_1): Prevent possibly
            trapping ops in different BBs.

            * gcc.dg/vect/bb-slp-pr100778-1.c: New testcase.

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

* [Bug tree-optimization/100778] [11/12 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (4 preceding siblings ...)
  2021-05-28 13:18 ` cvs-commit at gcc dot gnu.org
@ 2021-05-28 13:19 ` rguenth at gcc dot gnu.org
  2021-06-04 16:22 ` gabrielle.hugo at cern dot ch
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-28 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The fix pushed is for a related issue only, still working on the actual issue.

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

* [Bug tree-optimization/100778] [11/12 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (5 preceding siblings ...)
  2021-05-28 13:19 ` rguenth at gcc dot gnu.org
@ 2021-06-04 16:22 ` gabrielle.hugo at cern dot ch
  2021-07-01  8:18 ` rguenth at gcc dot gnu.org
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: gabrielle.hugo at cern dot ch @ 2021-06-04 16:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Gabrielle Hugo <gabrielle.hugo at cern dot ch> ---
Dear Richard,

Thanks a lot for confirming the bug, and for posting similar issue bugfix.
Will be interesting to understand why SLP vectorization is still too
aggressive.

Gabrielle

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

* [Bug tree-optimization/100778] [11/12 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (6 preceding siblings ...)
  2021-06-04 16:22 ` gabrielle.hugo at cern dot ch
@ 2021-07-01  8:18 ` rguenth at gcc dot gnu.org
  2021-07-01 10:31 ` cvs-commit at gcc dot gnu.org
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-01  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
C testcase for the torture testsuite that also triggers on trunk (which needs
-fno-tree-sink)

/* { dg-do run { target *-*-*gnu* } } */
/* { dg-additional-options "-fno-tree-sink -fno-math-errno -ftree-vectorize
-D_GNU_SOURCE" } */
/* { dg-require-effective-target fenv_exceptions } */

#include <fenv.h>

double a[2];
void __attribute__((noipa)) foo ()
{
  double x = a[0];
  double y = a[1];
  double norm = __builtin_sqrt (x*x + y*y);
  if (norm > 1.)
    {
      x = x / norm;
      y = y / norm;
    }
  a[0] = x;
  a[1] = y;
}

int main()
{
  feenableexcept (FE_INVALID);
  a[0] = 0.;
  a[1] = 0.;
  foo ();
  if (a[0] != 0. || a[1] != 0.)
    __builtin_abort ();
  return 0;
}

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

* [Bug tree-optimization/100778] [11/12 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (7 preceding siblings ...)
  2021-07-01  8:18 ` rguenth at gcc dot gnu.org
@ 2021-07-01 10:31 ` cvs-commit at gcc dot gnu.org
  2021-07-01 10:31 ` [Bug tree-optimization/100778] [11 " rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-01 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:a3aaba68405751bae3f630669515b7ecdf77efa6

commit r12-1951-ga3aaba68405751bae3f630669515b7ecdf77efa6
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jul 1 10:35:38 2021 +0200

    tree-optimization/100778 - fix placement of trapping vectorized ops

    This avoids placing possibly trapping vectorized operations where
    the corresponding scalar operation was possibly not executed.

    2021-01-07  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/100778
            * tree-vect-slp.c (vect_schedule_slp_node): Do not place trapping
            vectorized ops ahead of their scalar BB.

            * gcc.dg/torture/pr100778.c: New testcase.

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (8 preceding siblings ...)
  2021-07-01 10:31 ` cvs-commit at gcc dot gnu.org
@ 2021-07-01 10:31 ` rguenth at gcc dot gnu.org
  2021-07-02 11:12 ` gabrielle.hugo at cern dot ch
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-01 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |12.0
            Summary|[11/12 Regression] Get      |[11 Regression] Get SIGFPE
                   |SIGFPE on simple test with  |on simple test with
                   |-fpe-trap=invalid and SLP   |-fpe-trap=invalid and SLP
                   |vectorization ON, with      |vectorization ON, with
                   |gfortran 11.1.0 on x86_64   |gfortran 11.1.0 on x86_64

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (9 preceding siblings ...)
  2021-07-01 10:31 ` [Bug tree-optimization/100778] [11 " rguenth at gcc dot gnu.org
@ 2021-07-02 11:12 ` gabrielle.hugo at cern dot ch
  2021-07-02 11:41 ` rguenther at suse dot de
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: gabrielle.hugo at cern dot ch @ 2021-07-02 11:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Gabrielle Hugo <gabrielle.hugo at cern dot ch> ---
Awesome, thanks a lot Richard!


Applying your patch in tree-vect-slp.c to gcc 11, I now get the vectorized
division divpd after the if as expected:

      if (norm .gt. 1.D+00) then
  400826:       76 7b                   jbe    4008a3 <normalize_+0xb3>
  400828:       66 0f 28 d0             movapd %xmm0,%xmm2
         x = x / norm
         y = y / norm
         write (*, '(A,F5.3)') 'Normalized x and y.', norm
  40082c:       48 8b 05 c5 01 00 00    mov    0x1c5(%rip),%rax        # 4009f8
<options.2.0+0x28>
  400833:       48 8d 6c 24 10          lea    0x10(%rsp),%rbp
  400838:       48 c7 44 24 18 78 09    movq   $0x400978,0x18(%rsp)
  40083f:       40 00 
  400841:       66 0f 14 d2             unpcklpd %xmm2,%xmm2
  400845:       48 89 ef                mov    %rbp,%rdi
  400848:       c7 44 24 20 1d 00 00    movl   $0x1d,0x20(%rsp)
  40084f:       00 
         x = x / norm
  400850:       66 0f 5e ca             divpd  %xmm2,%xmm1


So if I understand correctly the fix in SLP vectorization 
(is_a <bb_vec_info> (vinfo)), 
when there are possibly trapping operations 
(gimple_could_trap_p (stmt_info->stmt)), 
is to explicitely constrain them to come from the same BB 
(special handling when gimple_bb (last_stmt) != gimple_bb (stmt_info->stmt) ).


Do I understand correctly that trunk is basically gcc 12.0, which will
eventually end up being released as gcc 12.1 ?
What about gcc 11, will this fix also make its way to the next gcc 11 release?

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (10 preceding siblings ...)
  2021-07-02 11:12 ` gabrielle.hugo at cern dot ch
@ 2021-07-02 11:41 ` rguenther at suse dot de
  2021-07-02 11:45 ` gabrielle.hugo at cern dot ch
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenther at suse dot de @ 2021-07-02 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 2 Jul 2021, gabrielle.hugo at cern dot ch wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100778
> 
> --- Comment #11 from Gabrielle Hugo <gabrielle.hugo at cern dot ch> ---
> Awesome, thanks a lot Richard!
> 
> 
> Applying your patch in tree-vect-slp.c to gcc 11, I now get the vectorized
> division divpd after the if as expected:
> 
>       if (norm .gt. 1.D+00) then
>   400826:       76 7b                   jbe    4008a3 <normalize_+0xb3>
>   400828:       66 0f 28 d0             movapd %xmm0,%xmm2
>          x = x / norm
>          y = y / norm
>          write (*, '(A,F5.3)') 'Normalized x and y.', norm
>   40082c:       48 8b 05 c5 01 00 00    mov    0x1c5(%rip),%rax        # 4009f8
> <options.2.0+0x28>
>   400833:       48 8d 6c 24 10          lea    0x10(%rsp),%rbp
>   400838:       48 c7 44 24 18 78 09    movq   $0x400978,0x18(%rsp)
>   40083f:       40 00 
>   400841:       66 0f 14 d2             unpcklpd %xmm2,%xmm2
>   400845:       48 89 ef                mov    %rbp,%rdi
>   400848:       c7 44 24 20 1d 00 00    movl   $0x1d,0x20(%rsp)
>   40084f:       00 
>          x = x / norm
>   400850:       66 0f 5e ca             divpd  %xmm2,%xmm1
> 
> 
> So if I understand correctly the fix in SLP vectorization 
> (is_a <bb_vec_info> (vinfo)), 
> when there are possibly trapping operations 
> (gimple_could_trap_p (stmt_info->stmt)), 
> is to explicitely constrain them to come from the same BB 
> (special handling when gimple_bb (last_stmt) != gimple_bb (stmt_info->stmt) ).

Yes.

> Do I understand correctly that trunk is basically gcc 12.0, which will
> eventually end up being released as gcc 12.1 ?

Yes.

> What about gcc 11, will this fix also make its way to the next gcc 11 release?

Yes, we're usually waiting a bit to see if fallout is detected by
autotesters before backporting to release branches.

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (11 preceding siblings ...)
  2021-07-02 11:41 ` rguenther at suse dot de
@ 2021-07-02 11:45 ` gabrielle.hugo at cern dot ch
  2021-07-12 10:19 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: gabrielle.hugo at cern dot ch @ 2021-07-02 11:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Gabrielle Hugo <gabrielle.hugo at cern dot ch> ---
>Yes, we're usually waiting a bit to see if fallout is detected by 
>autotesters before backporting to release branches.

Oki thanks!

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (12 preceding siblings ...)
  2021-07-02 11:45 ` gabrielle.hugo at cern dot ch
@ 2021-07-12 10:19 ` rguenth at gcc dot gnu.org
  2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-12 10:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100778
Bug 100778 depends on bug 101423, which changed state.

Bug 101423 Summary: [12 Regression] ICE in vect_schedule_slp_node, at tree-vect-slp.c:7113 since r12-1951-ga3aaba68405751ba
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101423

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (13 preceding siblings ...)
  2021-07-12 10:19 ` rguenth at gcc dot gnu.org
@ 2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
  2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-13 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1c2e5ab1468d959200334f2f5039d8d6af01f9fb

commit r11-8721-g1c2e5ab1468d959200334f2f5039d8d6af01f9fb
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 28 14:26:06 2021 +0200

    tree-optimization/100778 - avoid cross-BB vectorization of trapping op

    This avoids vectorizing a possibly trapping operation when lanes
    are handled in different BBs.  I spotted this when working on the
    originally reported issue in PR100778.

    2021-05-28  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/100778
            * tree-vect-slp.c (vect_build_slp_tree_1): Prevent possibly
            trapping ops in different BBs.

            * gcc.dg/vect/bb-slp-pr100778-1.c: New testcase.

    (cherry picked from commit f7a07f5a5d8065e7f11133dd1f4ad3510ab2195b)

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (14 preceding siblings ...)
  2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
@ 2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
  2021-07-13 11:01 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-13 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:f32145c27eec468247353b59ec5f62fcba3ae2c7

commit r11-8722-gf32145c27eec468247353b59ec5f62fcba3ae2c7
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jul 1 10:35:38 2021 +0200

    tree-optimization/100778 - fix placement of trapping vectorized ops

    This avoids placing possibly trapping vectorized operations where
    the corresponding scalar operation was possibly not executed.

    2021-01-07  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/100778
            * tree-vect-slp.c (vect_schedule_slp_node): Do not place trapping
            vectorized ops ahead of their scalar BB.

            * gcc.dg/torture/pr100778.c: New testcase.

    (cherry picked from commit a3aaba68405751bae3f630669515b7ecdf77efa6)

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (15 preceding siblings ...)
  2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
@ 2021-07-13 11:01 ` rguenth at gcc dot gnu.org
  2021-07-27 11:10 ` rguenth at gcc dot gnu.org
  2022-12-29  2:34 ` pinskia at gcc dot gnu.org
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-13 11:01 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |11.1.1
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
           Priority|P3                          |P2

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (16 preceding siblings ...)
  2021-07-13 11:01 ` rguenth at gcc dot gnu.org
@ 2021-07-27 11:10 ` rguenth at gcc dot gnu.org
  2022-12-29  2:34 ` pinskia at gcc dot gnu.org
  18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-27 11:10 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at wdqb dot uk

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 101634 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/100778] [11 Regression] Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64
  2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
                   ` (17 preceding siblings ...)
  2021-07-27 11:10 ` rguenth at gcc dot gnu.org
@ 2022-12-29  2:34 ` pinskia at gcc dot gnu.org
  18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-29  2:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 101634 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2022-12-29  2:34 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 18:42 [Bug fortran/100778] New: Get SIGFPE on simple test with -fpe-trap=invalid and SLP vectorization ON, with gfortran 11.1.0 on x86_64 gabrielle.hugo at cern dot ch
2021-05-26 19:25 ` [Bug fortran/100778] [11 Regression] " anlauf at gcc dot gnu.org
2021-05-26 19:39 ` [Bug tree-optimization/100778] " anlauf at gcc dot gnu.org
2021-05-28 10:28 ` rguenth at gcc dot gnu.org
2021-05-28 10:30 ` [Bug tree-optimization/100778] [11/12 " rguenth at gcc dot gnu.org
2021-05-28 13:18 ` cvs-commit at gcc dot gnu.org
2021-05-28 13:19 ` rguenth at gcc dot gnu.org
2021-06-04 16:22 ` gabrielle.hugo at cern dot ch
2021-07-01  8:18 ` rguenth at gcc dot gnu.org
2021-07-01 10:31 ` cvs-commit at gcc dot gnu.org
2021-07-01 10:31 ` [Bug tree-optimization/100778] [11 " rguenth at gcc dot gnu.org
2021-07-02 11:12 ` gabrielle.hugo at cern dot ch
2021-07-02 11:41 ` rguenther at suse dot de
2021-07-02 11:45 ` gabrielle.hugo at cern dot ch
2021-07-12 10:19 ` rguenth at gcc dot gnu.org
2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
2021-07-13 10:59 ` cvs-commit at gcc dot gnu.org
2021-07-13 11:01 ` rguenth at gcc dot gnu.org
2021-07-27 11:10 ` rguenth at gcc dot gnu.org
2022-12-29  2:34 ` pinskia at gcc dot gnu.org

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).