public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156
@ 2024-07-11  7:01 rguenth at gcc dot gnu.org
  2024-07-11  7:02 ` [Bug tree-optimization/115868] [14/15 Regression] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-11  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115868
           Summary: ICE: in exact_div, at poly-int.h:2156
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

g++.dg/vect/pr68762-2.cc ICEs when built with -march=znver4 (or -mavx512vl) and
--param vect-partial-vector-usage=1 or 2.

during GIMPLE pass: vect
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:8:1:
internal compiler error: in exact_div, at poly-int.h:2156
0x161ffaf poly_int<1u, poly_result<unsigned long, if_nonpoly<unsigned long,
unsigned long, poly_int_traits<unsigned long>::is_poly>::type,
poly_coeff_pair_traits<unsigned long, if_nonpoly<unsigned long, unsigned long,
poly_int_traits<unsigned long>::is_poly>::type>::result_kind>::type>
exact_div<1u, unsigned long, unsigned long>(poly_int<1u, unsigned long> const&,
unsigned long)
        /space/rguenther/src/gcc-14-branch/gcc/poly-int.h:2156
0x161d761 poly_int<1u, poly_result<unsigned long, unsigned long,
poly_coeff_pair_traits<unsigned long, unsigned long>::result_kind>::type>
exact_div<1u, unsigned long, unsigned long>(poly_int<1u, unsigned long> const&,
poly_int<1u, unsigned long> const&)
        /space/rguenther/src/gcc-14-branch/gcc/poly-int.h:2169
0x1ea42b6 vect_verify_full_masking
        /space/rguenther/src/gcc-14-branch/gcc/tree-vect-loop.cc:1326

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

* [Bug tree-optimization/115868] [14/15 Regression] ICE: in exact_div, at poly-int.h:2156
  2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
@ 2024-07-11  7:02 ` rguenth at gcc dot gnu.org
  2024-07-11  7:44 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-11  7:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|ICE: in exact_div, at       |[14/15 Regression] ICE: in
                   |poly-int.h:2156             |exact_div, at
                   |                            |poly-int.h:2156
      Known to work|                            |13.3.1
             Blocks|                            |53947
      Known to fail|                            |14.1.1, 15.0
             Target|                            |x86_64-*-*
   Target Milestone|---                         |14.2


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

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

* [Bug tree-optimization/115868] [14/15 Regression] ICE: in exact_div, at poly-int.h:2156
  2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
  2024-07-11  7:02 ` [Bug tree-optimization/115868] [14/15 Regression] " rguenth at gcc dot gnu.org
@ 2024-07-11  7:44 ` rguenth at gcc dot gnu.org
  2024-07-13 11:30 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-11  7:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2024-07-11

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
(gdb) l
1321            masks->rgc_vec.safe_grow_cleared (nvectors, true);
1322          rgroup_controls *rgm = &(*masks).rgc_vec[nvectors - 1];
1323          /* The number of scalars per iteration and the number of vectors
are
1324             both compile-time constants.  */
1325          unsigned int nscalars_per_iter
1326              = exact_div (nvectors * TYPE_VECTOR_SUBPARTS (vectype),
1327                           LOOP_VINFO_VECT_FACTOR (loop_vinfo)).to_constant
();
1328
1329          if (rgm->max_nscalars_per_iter < nscalars_per_iter)
1330            {
(gdb) p nvectors
$1 = 1
(gdb) p debug_generic_expr (vectype)
vector(4) double
$2 = void
(gdb) p loop_vinfo->vectorization_factor 
$3 = {coeffs = {8}}

it looks we create an inbranch variant (even if unused) and vectorize that.
The key might be .MASK_CALL support here which gets a bool argument and

/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   ==> examining statement: _2 = .MASK_CALL (baz, d_1, _19);
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   get vectype for scalar type: double
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   vectype: vector(4) double
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   nunits = 4
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   ==> examining statement: _32 = ~_19;
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   vectype: vector(8) <signed-boolean:1>
/space/rguenther/src/gcc-14-branch/gcc/testsuite/g++.dg/vect/pr68762.h:10:14:
note:   nunits = 8

something goes wrong with registering loop masks here I think.  I think
that in vectorizable_simd_clone_call when doing

            case SIMD_CLONE_ARG_TYPE_MASK:
              if (loop_vinfo
                  && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo))
                vect_record_loop_mask (loop_vinfo,
                                       &LOOP_VINFO_MASKS (loop_vinfo),
                                       ncopies, vectype, op);

we're not properly considering that a SIMD call can have a larger vector
argument composed of _two_ inputs (though 'vectype' here is for the result).

Note that ncopies is based on the simdlen of the function.  As said we can
at least handle input merging and destination splitting:

  _50 = {vect_d_1.253_41, vect_d_1.254_43};
  _51 = VIEW_CONVERT_EXPR<unsigned char>(mask__19.257_49);
  _52 = (unsigned int) _51;
  _53 = _Z3bazd.simdclone.7 (_50, _52);
  _54 = BIT_FIELD_REF <_53, 256, 0>;
  _55 = BIT_FIELD_REF <_53, 256, 256>;

I do not remember whether we support non-uniform argument/return types
or if the SIMD ABI can require splitting an argument into two.

The following fixes this:

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 21e8fe98e44..73408f2c6d4 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -4317,9 +4317,14 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
            case SIMD_CLONE_ARG_TYPE_MASK:
              if (loop_vinfo
                  && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo))
-               vect_record_loop_mask (loop_vinfo,
-                                      &LOOP_VINFO_MASKS (loop_vinfo),
-                                      ncopies, vectype, op);
+               {
+                 unsigned mult
+                   = exact_div (bestn->simdclone->simdlen,
+                                TYPE_VECTOR_SUBPARTS (vectype)).to_constant
();
+                 vect_record_loop_mask (loop_vinfo,
+                                        &LOOP_VINFO_MASKS (loop_vinfo),
+                                        ncopies * mult, vectype, op);
+               }

              break;
            }

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

* [Bug tree-optimization/115868] [14/15 Regression] ICE: in exact_div, at poly-int.h:2156
  2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
  2024-07-11  7:02 ` [Bug tree-optimization/115868] [14/15 Regression] " rguenth at gcc dot gnu.org
  2024-07-11  7:44 ` rguenth at gcc dot gnu.org
@ 2024-07-13 11:30 ` cvs-commit at gcc dot gnu.org
  2024-07-13 11:30 ` [Bug tree-optimization/115868] [14 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-07-13 11:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC 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:abf3964711f05b6858d9775c3595ec2b45483e14

commit r15-2014-gabf3964711f05b6858d9775c3595ec2b45483e14
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jul 11 09:56:56 2024 +0200

    tree-optimization/115868 - ICE with .MASK_CALL in simdclone

    The following adjusts mask recording which didn't take into account
    that we can merge call arguments from two vectors like

      _50 = {vect_d_1.253_41, vect_d_1.254_43};
      _51 = VIEW_CONVERT_EXPR<unsigned char>(mask__19.257_49);
      _52 = (unsigned int) _51;
      _53 = _Z3bazd.simdclone.7 (_50, _52);
      _54 = BIT_FIELD_REF <_53, 256, 0>;
      _55 = BIT_FIELD_REF <_53, 256, 256>;

    The testcase g++.dg/vect/pr68762-2.cc exercises this on x86_64 with
    partial vector usage enabled and AVX512 support.

            PR tree-optimization/115868
            * tree-vect-stmts.cc (vectorizable_simd_clone_call): Correctly
            compute the number of mask copies required for
vect_record_loop_mask.

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

* [Bug tree-optimization/115868] [14 Regression] ICE: in exact_div, at poly-int.h:2156
  2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-07-13 11:30 ` cvs-commit at gcc dot gnu.org
@ 2024-07-13 11:30 ` rguenth at gcc dot gnu.org
  2024-07-17  7:30 ` cvs-commit at gcc dot gnu.org
  2024-07-17  8:43 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-13 11:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |15.0
           Priority|P3                          |P2
            Summary|[14/15 Regression] ICE: in  |[14 Regression] ICE: in
                   |exact_div, at               |exact_div, at
                   |poly-int.h:2156             |poly-int.h:2156
      Known to fail|15.0                        |

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

* [Bug tree-optimization/115868] [14 Regression] ICE: in exact_div, at poly-int.h:2156
  2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-07-13 11:30 ` [Bug tree-optimization/115868] [14 " rguenth at gcc dot gnu.org
@ 2024-07-17  7:30 ` cvs-commit at gcc dot gnu.org
  2024-07-17  8:43 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-07-17  7:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r14-10443-gc58bede01c06c84f0b36881fafd1e5d6456a38f4
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jul 11 09:56:56 2024 +0200

    tree-optimization/115868 - ICE with .MASK_CALL in simdclone

    The following adjusts mask recording which didn't take into account
    that we can merge call arguments from two vectors like

      _50 = {vect_d_1.253_41, vect_d_1.254_43};
      _51 = VIEW_CONVERT_EXPR<unsigned char>(mask__19.257_49);
      _52 = (unsigned int) _51;
      _53 = _Z3bazd.simdclone.7 (_50, _52);
      _54 = BIT_FIELD_REF <_53, 256, 0>;
      _55 = BIT_FIELD_REF <_53, 256, 256>;

    The testcase g++.dg/vect/pr68762-2.cc exercises this on x86_64 with
    partial vector usage enabled and AVX512 support.

            PR tree-optimization/115868
            * tree-vect-stmts.cc (vectorizable_simd_clone_call): Correctly
            compute the number of mask copies required for
vect_record_loop_mask.

    (cherry picked from commit abf3964711f05b6858d9775c3595ec2b45483e14)

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

* [Bug tree-optimization/115868] [14 Regression] ICE: in exact_div, at poly-int.h:2156
  2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-07-17  7:30 ` cvs-commit at gcc dot gnu.org
@ 2024-07-17  8:43 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-17  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2024-07-17  8:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-11  7:01 [Bug tree-optimization/115868] New: ICE: in exact_div, at poly-int.h:2156 rguenth at gcc dot gnu.org
2024-07-11  7:02 ` [Bug tree-optimization/115868] [14/15 Regression] " rguenth at gcc dot gnu.org
2024-07-11  7:44 ` rguenth at gcc dot gnu.org
2024-07-13 11:30 ` cvs-commit at gcc dot gnu.org
2024-07-13 11:30 ` [Bug tree-optimization/115868] [14 " rguenth at gcc dot gnu.org
2024-07-17  7:30 ` cvs-commit at gcc dot gnu.org
2024-07-17  8:43 ` 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).