public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897
@ 2021-06-09  3:26 asolokha at gmx dot com
  2021-06-09  6:48 ` [Bug tree-optimization/100981] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: asolokha at gmx dot com @ 2021-06-09  3:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100981
           Summary: ICE in info_for_reduction, at tree-vect-loop.c:4897
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---
            Target: aarch64-linux-gnu

gfortran-12.0.0-alpha20210606 snapshot
(g:fed94fc9e704b0de228499495b7ca4d4c79ef76b) ICEs when compiling the following
testcase w/ -march=armv8.3-a -O3 -ftree-parallelize-loops=2 -fno-signed-zeros
-fno-trapping-math:

complex function cdcdot(n, cx)
  implicit none

  integer :: n, i, kx
  complex :: cx(*)
  double precision :: dsdotr, dsdoti, dt1, dt3

  kx = 1
  do i = 1, n
     dt1 = real(cx(kx))
     dt3 = aimag(cx(kx))
     dsdotr = dsdotr + dt1 * 2 - dt3 * 2
     dsdoti = dsdoti + dt1 * 2 + dt3 * 2
     kx = kx + 1
  end do
  cdcdot = cmplx(real(dsdotr), real(dsdoti))
  return
end function cdcdot

% aarch64-linux-gnu-gfortran-12.0.0 -march=armv8.3-a -O3
-ftree-parallelize-loops=2 -fno-signed-zeros -fno-trapping-math -c xrvsc8ow.f90
during GIMPLE pass: vect
xrvsc8ow.f90:9:8:

    9 |   do i = 1, n
      |        ^
internal compiler error: in info_for_reduction, at tree-vect-loop.c:4897
0x7c8b0d info_for_reduction(vec_info*, _stmt_vec_info*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-loop.c:4897
0x122d008 vectorizable_live_operation(vec_info*, _stmt_vec_info*,
gimple_stmt_iterator*, _slp_tree*, _slp_instance*, int, bool,
vec<stmt_info_for_cost, va_heap, vl_ptr>*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-loop.c:8547
0x11ed1d7 can_vectorize_live_stmts
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-stmts.c:10619
0x1216858 vect_transform_stmt(vec_info*, _stmt_vec_info*,
gimple_stmt_iterator*, _slp_tree*, _slp_instance*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-stmts.c:11003
0x124b296 vect_schedule_slp_node
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-slp.c:6302
0x12596cc vect_schedule_scc
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-slp.c:6516
0x125a71f vect_schedule_slp(vec_info*, vec<_slp_instance*, va_heap, vl_ptr>)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-slp.c:6580
0x1236e7c vect_transform_loop(_loop_vec_info*, gimple*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vect-loop.c:9538
0x1265f0f try_vectorize_loop_1
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vectorizer.c:1104
0x1266ca0 vectorize_loops()
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_alpha20210606/work/gcc-12-20210606/gcc/tree-vectorizer.c:1243

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
@ 2021-06-09  6:48 ` rguenth at gcc dot gnu.org
  2021-06-09  7:33 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-06-09
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
  2021-06-09  6:48 ` [Bug tree-optimization/100981] " rguenth at gcc dot gnu.org
@ 2021-06-09  7:33 ` rguenth at gcc dot gnu.org
  2021-06-09  7:34 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09  7:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |avieira at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
#1  0x0000000001816089 in info_for_reduction (vinfo=0x369bf80, 
    stmt_info=0x376e340) at ../../src/trunk/gcc/tree-vect-loop.c:4897
4897      gcc_assert (STMT_VINFO_REDUC_DEF (stmt_info));
(gdb) p debug_gimple_stmt ($1)
slp_patt_96 = .COMPLEX_FMA (dsdotr.5_21, dsdotr.5_21, dsdotr.5_21);
$2 = void

ah, so we get a reduction stmt SLP pattern-recognized...  and while
the original scalar stmt_infos are preserved:

t.f90:9:8: note: node 0x35cff60 (max_nunits=4, refcnt=2)
t.f90:9:8: note: op template: slp_patt_96 = .COMPLEX_FMA (dsdotr.5_21,
dsdotr.5_21, dsdotr.5_21);
t.f90:9:8: note:        stmt 0 dsdotr.5_21 = dsdotr.5_20 + _36;
t.f90:9:8: note:        stmt 1 dsdoti.4_19 = dsdoti.4_18 + _37;
t.f90:9:8: note:        children 0x35cffe8 0x35d0648 0x35d0290

the reduc-info, which is originally attached to the SLP nodes
representative is no longer there (it didn't get transfered).

Now, actually handling this needs some double-checking and turning the
testcase into a runtime one.  I'll poke on doing that.

The issue is probably latent on the branch where we might want to play
safer and simply refuse to pattern recog nodes with a
STMT_VINFO_REDUC_DEF (vect_orig_stmt (SLP_TREE_REPRESENTATIVE (node))).

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
  2021-06-09  6:48 ` [Bug tree-optimization/100981] " rguenth at gcc dot gnu.org
  2021-06-09  7:33 ` rguenth at gcc dot gnu.org
@ 2021-06-09  7:34 ` rguenth at gcc dot gnu.org
  2021-06-09  7:55 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 50969
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50969&action=edit
patch fixing the ICE

So this fixes the ICE but I'm not sure whether correct code is generated yet.

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2021-06-09  7:34 ` rguenth at gcc dot gnu.org
@ 2021-06-09  7:55 ` rguenth at gcc dot gnu.org
  2021-06-09 12:34 ` avieira at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09  7:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Runtime testcase (not sure if sufficient ...).  Andre - can you verify it
passes runtime testing with the patch on HW that supports the complex mul?

complex function cdcdot(n, cx)
  implicit none

  integer :: n, i, kx
  complex :: cx(*)
  double precision :: dsdotr, dsdoti, dt1, dt3

  kx = 1
  do i = 1, n
     dt1 = real(cx(kx))
     dt3 = aimag(cx(kx))
     dsdotr = dsdotr + dt1 * 2 - dt3 * 2
     dsdoti = dsdoti + dt1 * 2 + dt3 * 2
     kx = kx + 1
  end do
  cdcdot = cmplx(real(dsdotr), real(dsdoti))
  return
end function cdcdot
program test
  implicit none
  complex :: cx(100), ct, cdcdot
  integer :: i
  do i = 1, 100
    cx(i) = cmplx(2*i, i)
  end do
  ct = cdcdot (100, cx)
  if (ct.ne.cmplx(10100.0000,30300.0000)) call abort
end

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2021-06-09  7:55 ` rguenth at gcc dot gnu.org
@ 2021-06-09 12:34 ` avieira at gcc dot gnu.org
  2021-06-09 14:23 ` avieira at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: avieira at gcc dot gnu.org @ 2021-06-09 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from avieira at gcc dot gnu.org ---
Yeah that works. Ran it as is, no abort, ran it with s/ne/eq/ and it aborts.

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2021-06-09 12:34 ` avieira at gcc dot gnu.org
@ 2021-06-09 14:23 ` avieira at gcc dot gnu.org
  2021-06-09 14:35 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: avieira at gcc dot gnu.org @ 2021-06-09 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from avieira at gcc dot gnu.org ---
FYI Tamar asked me to make sure the instructions were being generated. I
checked and they were, but not being used as it decides to inline MAIN__ and
inlining seems to break (as in not apply/missed oppurtunity) the complex
optimization.

So for this specific test I'd use -fno-inline, it executes the fcmla
instructions that way and it runs fine.

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

* [Bug tree-optimization/100981] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2021-06-09 14:23 ` avieira at gcc dot gnu.org
@ 2021-06-09 14:35 ` cvs-commit at gcc dot gnu.org
  2021-06-09 14:36 ` [Bug tree-optimization/100981] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-09 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 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:374f93da97fb0378453d503f3cfea4d7a923a89c

commit r12-1330-g374f93da97fb0378453d503f3cfea4d7a923a89c
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jun 9 14:48:35 2021 +0200

    tree-optimization/100981 - fix SLP patterns involving reductions

    The following fixes the SLP FMA patterns to preserve reduction
    info and the reduction vectorization to consider internal function
    call defs for the reduction stmt.

    2021-06-09  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/100981
    gcc/
            * tree-vect-loop.c (vect_create_epilog_for_reduction): Use
            gimple_get_lhs to also handle calls.
            * tree-vect-slp-patterns.c (complex_pattern::build): Transfer
            reduction info.

    gcc/testsuite/
            * gfortran.dg/vect/pr100981-1.f90: New testcase.

    libgomp/
            * testsuite/libgomp.fortran/pr100981-2.f90: New testcase.

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

* [Bug tree-optimization/100981] [11 Regression] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2021-06-09 14:35 ` cvs-commit at gcc dot gnu.org
@ 2021-06-09 14:36 ` rguenth at gcc dot gnu.org
  2021-06-10  7:32 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE in info_for_reduction,  |[11 Regression] ICE in
                   |at tree-vect-loop.c:4897    |info_for_reduction, at
                   |                            |tree-vect-loop.c:4897
   Target Milestone|---                         |11.2
      Known to work|                            |12.0
           Priority|P3                          |P2

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar, the issue is most likely latent on the branch.

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

* [Bug tree-optimization/100981] [11 Regression] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2021-06-09 14:36 ` [Bug tree-optimization/100981] [11 Regression] " rguenth at gcc dot gnu.org
@ 2021-06-10  7:32 ` cvs-commit at gcc dot gnu.org
  2021-06-16 13:12 ` cvs-commit at gcc dot gnu.org
  2021-06-16 13:13 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-10  7:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:7d19a50ea1e5e9858bb7cd258fa4f9db89ecfcb2

commit r12-1355-g7d19a50ea1e5e9858bb7cd258fa4f9db89ecfcb2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jun 10 09:31:06 2021 +0200

    testsuite: Fix up libgomp.fortran/pr100981-2.f90 testcase [PR100981]

    The dsdotr and dsdoti variables uninitialized and the testcase fails e.g.
    on i686-linux.  Fixed by zero initialization.

    2021-06-10  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/100981
            * testsuite/libgomp.fortran/pr100981-2.f90 (cdcdot): Initialize
            dsdotr and dsdoti to 0.

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

* [Bug tree-optimization/100981] [11 Regression] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (8 preceding siblings ...)
  2021-06-10  7:32 ` cvs-commit at gcc dot gnu.org
@ 2021-06-16 13:12 ` cvs-commit at gcc dot gnu.org
  2021-06-16 13:13 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-16 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 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:68d2dbf845d8589c2a227a3097cbcff9429244b0

commit r11-8580-g68d2dbf845d8589c2a227a3097cbcff9429244b0
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jun 9 14:48:35 2021 +0200

    tree-optimization/100981 - fix SLP patterns involving reductions

    The following fixes the SLP FMA patterns to preserve reduction
    info and the reduction vectorization to consider internal function
    call defs for the reduction stmt.

    2021-06-09  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/100981
    gcc/
            * tree-vect-loop.c (vect_create_epilog_for_reduction): Use
            gimple_get_lhs to also handle calls.
            * tree-vect-slp-patterns.c (complex_pattern::build): Transfer
            reduction info.

    gcc/testsuite/
            * gfortran.dg/vect/pr100981-1.f90: New testcase.

    libgomp/
            * testsuite/libgomp.fortran/pr100981-2.f90: New testcase.

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

* [Bug tree-optimization/100981] [11 Regression] ICE in info_for_reduction, at tree-vect-loop.c:4897
  2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
                   ` (9 preceding siblings ...)
  2021-06-16 13:12 ` cvs-commit at gcc dot gnu.org
@ 2021-06-16 13:13 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-16 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|                            |11.1.0
      Known to work|                            |11.1.1
         Resolution|---                         |FIXED

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

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

end of thread, other threads:[~2021-06-16 13:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  3:26 [Bug target/100981] New: ICE in info_for_reduction, at tree-vect-loop.c:4897 asolokha at gmx dot com
2021-06-09  6:48 ` [Bug tree-optimization/100981] " rguenth at gcc dot gnu.org
2021-06-09  7:33 ` rguenth at gcc dot gnu.org
2021-06-09  7:34 ` rguenth at gcc dot gnu.org
2021-06-09  7:55 ` rguenth at gcc dot gnu.org
2021-06-09 12:34 ` avieira at gcc dot gnu.org
2021-06-09 14:23 ` avieira at gcc dot gnu.org
2021-06-09 14:35 ` cvs-commit at gcc dot gnu.org
2021-06-09 14:36 ` [Bug tree-optimization/100981] [11 Regression] " rguenth at gcc dot gnu.org
2021-06-10  7:32 ` cvs-commit at gcc dot gnu.org
2021-06-16 13:12 ` cvs-commit at gcc dot gnu.org
2021-06-16 13:13 ` rguenth 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).