public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239
@ 2021-12-18  4:23 asolokha at gmx dot com
  2021-12-18  4:36 ` [Bug tree-optimization/103761] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: asolokha at gmx dot com @ 2021-12-18  4:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103761
           Summary: [12 Regression] ICE in exact_div, at poly-int.h:2239
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
                CC: rsandifo at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64-linux-gnu

+++ This bug was initially created as a clone of Bug #103744 +++

gcc 12.0.0 alpha20211212 snapshot (g:0b52083ea2c2dd9897031fdc3802a68fd4aa45ef)
ICEs when compiling the following testcase w/ -mcpu=a64fx -O2
-fno-tree-scev-cprop:

short int *s;

int
foo (int r, int z)
{
  int *a;

  while (z < 1)
    {
      int i;

      i = *s;
      s += 2;
      r += a[i];
      r += a[i];
      z += 1;
    }

  return r;
}

% aarch64-linux-gnu-gcc-12.0.0 -mcpu=a64fx -O2 -fno-tree-scev-cprop -c
egbadqtv.c
during GIMPLE pass: vect
egbadqtv.c: In function 'foo':
egbadqtv.c:4:1: internal compiler error: in exact_div, at poly-int.h:2239
    4 | foo (int r, int z)
      | ^~~
0x7dd13e poly_int<2u, poly_result<unsigned long, unsigned long,
poly_coeff_pair_traits<unsigned long, unsigned long>::result_kind>::type>
exact_div<2u, unsigned long, unsigned long>(poly_int_pod<2u, unsigned long>
const&, poly_int_pod<2u, unsigned long> const&)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/poly-int.h:2239
0x7defbe poly_int<2u, poly_result<unsigned long, unsigned long,
poly_coeff_pair_traits<unsigned long, unsigned long>::result_kind>::type>
exact_div<2u, unsigned long, unsigned long>(poly_int_pod<2u, unsigned long>
const&, poly_int_pod<2u, unsigned long> const&)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/poly-int.h:2242
0x7defbe vect_record_loop_mask(_loop_vec_info*, auto_vec<rgroup_controls,
0ul>*, unsigned int, tree_node*, tree_node*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-loop.c:9060
0x1c978ba vectorizable_load
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-stmts.c:8875
0x1c9fe6a vect_analyze_stmt(vec_info*, _stmt_vec_info*, bool*, _slp_tree*,
_slp_instance*, vec<stmt_info_for_cost, va_heap, vl_ptr>*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-stmts.c:11086
0x120b698 vect_slp_analyze_node_operations_1
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-slp.c:4481
0x120b698 vect_slp_analyze_node_operations
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-slp.c:4640
0x120b578 vect_slp_analyze_node_operations
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-slp.c:4620
0x120df26 vect_slp_analyze_operations(vec_info*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-slp.c:4879
0x11e609e vect_analyze_loop_2
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-loop.c:2412
0x11e7f32 vect_analyze_loop_1
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-loop.c:2830
0x11e84d1 vect_analyze_loop(loop*, vec_info_shared*)
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vect-loop.c:2952
0x121e227 try_vectorize_loop_1
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vectorizer.c:1047
0x121e227 try_vectorize_loop
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vectorizer.c:1162
0x121ef74 execute
       
/var/tmp/portage/cross-aarch64-linux-gnu/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree-vectorizer.c:1278

It was originally reported in PR103744 comment 4.

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

* [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239
  2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
@ 2021-12-18  4:36 ` pinskia at gcc dot gnu.org
  2021-12-20 10:05 ` [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-18  4:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

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

* [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc
  2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
  2021-12-18  4:36 ` [Bug tree-optimization/103761] " pinskia at gcc dot gnu.org
@ 2021-12-20 10:05 ` marxin at gcc dot gnu.org
  2022-01-04 12:42 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-20 10:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org
            Summary|[12 Regression] ICE in      |[12 Regression] ICE in
                   |exact_div, at               |exact_div, at
                   |poly-int.h:2239             |poly-int.h:2239 since
                   |                            |r12-5612-g10833849b55401a52
                   |                            |f2334eb032a70beb688e9fc
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-12-20

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc.

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

* [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc
  2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
  2021-12-18  4:36 ` [Bug tree-optimization/103761] " pinskia at gcc dot gnu.org
  2021-12-20 10:05 ` [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc marxin at gcc dot gnu.org
@ 2022-01-04 12:42 ` rguenth at gcc dot gnu.org
  2022-03-08 13:35 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-04 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc
  2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2022-01-04 12:42 ` rguenth at gcc dot gnu.org
@ 2022-03-08 13:35 ` rguenth at gcc dot gnu.org
  2022-04-06  7:56 ` cvs-commit at gcc dot gnu.org
  2022-04-06  7:57 ` rsandifo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-08 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rsandifo at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed btw,

#1  0x0000000000f8b9b2 in exact_div<2u, unsigned long, unsigned long> (a=...,
b=...)
    at /home/rguenther/src/trunk/gcc/poly-int.h:2239
2239      gcc_checking_assert (a.coeffs[0] % b.coeffs[0] == 0);
(gdb) p a
$3 = (const poly_int_pod<2, unsigned long> &) @0x7fffffffada0: {coeffs = {4,
4}}
(gdb) p b
$4 = (const poly_int_pod<2, unsigned long> &) @0x3862a00: {coeffs = {8, 8}}

8916          if (loop_vinfo
8917              && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo))
8918            check_load_store_for_partial_vectors (loop_vinfo, vectype,
VLS_LOAD,
8919                                                  group_size,
memory_access_type,
8920                                                  ncopies, &gs_info, mask);

passes down ncopies == 1 but with SLP this is always one.  From what
vect_record_loop_mask does it looks like it would do OK with just
SLP_TREE_NUMBER_OF_VEC_STMTS.  The following works for the testcase but
the APIs are somewhat iffy (I guess I need to think on how to merge the
SLP vs. non-SLP idea of "ncopies").

Richard, can you take over from this?  Test coverage on x86-64 is zero here.

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 5c9e8cfefa5..3304df26842 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -8917,7 +8917,10 @@ vectorizable_load (vec_info *vinfo,
          && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo))
        check_load_store_for_partial_vectors (loop_vinfo, vectype, VLS_LOAD,
                                              group_size, memory_access_type,
-                                             ncopies, &gs_info, mask);
+                                             slp_node
+                                             ? SLP_TREE_NUMBER_OF_VEC_STMTS
+                                                 (slp_node) : ncopies,
+                                             &gs_info, mask);

       if (dump_enabled_p ()
          && memory_access_type != VMAT_ELEMENTWISE

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

* [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc
  2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2022-03-08 13:35 ` rguenth at gcc dot gnu.org
@ 2022-04-06  7:56 ` cvs-commit at gcc dot gnu.org
  2022-04-06  7:57 ` rsandifo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-06  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

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

commit r12-8016-gd037d9ad323ec9eef3e50c6e2cbc1e31191daa5d
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Wed Apr 6 08:56:07 2022 +0100

    vect: Fix mask handling for SLP gathers [PR103761]

    check_load_store_for_partial_vectors predates the support for SLP
    gathers and so had a hard-coded assumption that gathers/scatters
    (and load/stores lanes) would be non-SLP operations.  This patch
    passes down the slp_node so that the routine can work out how
    many vectors are needed in both the SLP and non-SLP cases.

    gcc/
            PR tree-optimization/103761
            * tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Replace
            the ncopies parameter with an slp_node parameter.  Calculate the
            number of vectors based on it and vectype.  Rename lambda to
            group_memory_nvectors.
            (vectorizable_store, vectorizable_load): Update calls accordingly.

    gcc/testsuite/
            PR tree-optimization/103761
            * gcc.dg/vect/pr103761.c: New test.
            * gcc.target/aarch64/sve/pr103761.c: Likewise.

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

* [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc
  2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2022-04-06  7:56 ` cvs-commit at gcc dot gnu.org
@ 2022-04-06  7:57 ` rsandifo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2022-04-06  7:57 UTC (permalink / raw)
  To: gcc-bugs

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

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

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

--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-04-06  7:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18  4:23 [Bug tree-optimization/103761] New: [12 Regression] ICE in exact_div, at poly-int.h:2239 asolokha at gmx dot com
2021-12-18  4:36 ` [Bug tree-optimization/103761] " pinskia at gcc dot gnu.org
2021-12-20 10:05 ` [Bug tree-optimization/103761] [12 Regression] ICE in exact_div, at poly-int.h:2239 since r12-5612-g10833849b55401a52f2334eb032a70beb688e9fc marxin at gcc dot gnu.org
2022-01-04 12:42 ` rguenth at gcc dot gnu.org
2022-03-08 13:35 ` rguenth at gcc dot gnu.org
2022-04-06  7:56 ` cvs-commit at gcc dot gnu.org
2022-04-06  7:57 ` rsandifo 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).