public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
@ 2024-06-18 11:12 tnfchris at gcc dot gnu.org
  2024-06-18 11:46 ` [Bug tree-optimization/115537] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2024-06-18 11:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115537
           Summary: [15 Regression] vectorizable_reduction ICEs after
                    g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tnfchris at gcc dot gnu.org
                CC: rguenth at gcc dot gnu.org
  Target Milestone: ---

testcase:

---
char *a;
int b;
void c() {
  int d = 0, e = 0, f;
  for (; f; ++f)
    if (a[f] == 5)
      ;
    else if (a[f])
      e = 1;
    else
      d = 1;
  if (d)
    if (e)
      b = 0;
}
---

compiled with -mcpu=neoverse-v1 -O3 produces the following ICE:

during GIMPLE pass: vect
pngrtran.i: In function 'c':
pngrtran.i:3:6: internal compiler error: in vectorizable_reduction, at
tree-vect-loop.cc:8335
    3 | void c() {
      |      ^
0xff74ff vectorizable_reduction(_loop_vec_info*, _stmt_vec_info*, _slp_tree*,
_slp_instance*, vec<stmt_info_for_cost, va_heap, vl_ptr>*)
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:8335
0x1b598f7 vect_analyze_stmt(vec_info*, _stmt_vec_info*, bool*, _slp_tree*,
_slp_instance*, vec<stmt_info_for_cost, va_heap, vl_ptr>*)
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-stmts.cc:13353
0x10225df vect_slp_analyze_node_operations_1
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:6457
0x10225df vect_slp_analyze_node_operations
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:6656
0x102253f vect_slp_analyze_node_operations
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:6635
0x1023ec3 vect_slp_analyze_operations(vec_info*)
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:7053
0xff816f vect_analyze_loop_2
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:2953
0xff9fb7 vect_analyze_loop_1
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:3484
0xffa6f7 vect_analyze_loop(loop*, vec_info_shared*)
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:3642
0x1035547 try_vectorize_loop_1
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vectorizer.cc:1067
0x1035547 try_vectorize_loop
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vectorizer.cc:1183
0x1035a5b execute
        /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vectorizer.cc:1299
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

after:

commit d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jun 13 14:42:25 2024 +0200

    Support single def-use cycle optimization for SLP reduction vectorization

    We can at least mimic single def-use cycle optimization when doing
    single-lane SLP reductions and that's required to avoid regressing
    compared to non-SLP.

            * tree-vect-loop.cc (vectorizable_reduction): Allow
            single-def-use cycles with SLP.
            (vect_transform_reduction): Handle SLP single def-use cycles.
            (vect_transform_cycle_phi): Likewise.

            * gcc.dg/vect/slp-reduc-12.c: New testcase.

 gcc/testsuite/gcc.dg/vect/slp-reduc-12.c | 18 +++++++++++++
 gcc/tree-vect-loop.cc                    | 45 +++++++++++++++++++-------------
 2 files changed, 45 insertions(+), 18 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/slp-reduc-12.c
bisect run success

looks like it's hitting the assert:

      gcc_assert (op.code != COND_EXPR);

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

* [Bug tree-optimization/115537] [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
  2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
@ 2024-06-18 11:46 ` rguenth at gcc dot gnu.org
  2024-06-18 12:00 ` 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-06-18 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-06-18
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

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

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

* [Bug tree-optimization/115537] [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
  2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
  2024-06-18 11:46 ` [Bug tree-optimization/115537] " rguenth at gcc dot gnu.org
@ 2024-06-18 12:00 ` rguenth at gcc dot gnu.org
  2024-06-18 13:28 ` 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-06-18 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
So w/o SLP we reject this with

  if ((double_reduc || reduction_type != TREE_CODE_REDUCTION)
      && ncopies > 1)
    {         
      if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                         "multiple types in double reduction or condition "
                         "reduction or fold-left reduction.\n");
      return false;

reduction_type is EXTRACT_LAST_REDUCTION here.  For SLP we only disallow

  if ((reduction_type == COND_REDUCTION
       || reduction_type == INTEGER_INDUC_COND_REDUCTION
       || reduction_type == CONST_COND_REDUCTION)
      && slp_node
      && SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) > 1)
    {                            
      if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                         "multiple types in condition reduction reduction.\n");
      return false;
    }

I've recently fixed a fold-left reduction case with multiple types
which we handle just fine.  I have a patch amending the above condition
(EXTRACT_LAST is an optimized COND_REDUCTION).

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

* [Bug tree-optimization/115537] [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
  2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
  2024-06-18 11:46 ` [Bug tree-optimization/115537] " rguenth at gcc dot gnu.org
  2024-06-18 12:00 ` rguenth at gcc dot gnu.org
@ 2024-06-18 13:28 ` cvs-commit at gcc dot gnu.org
  2024-06-18 13:28 ` 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-06-18 13:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:7f9be55a4630134a237219af9cc8143e02080380

commit r15-1407-g7f9be55a4630134a237219af9cc8143e02080380
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jun 18 14:00:52 2024 +0200

    tree-optimization/115537 - ICE with SLP condition reduction vectorization

    The condition rejecting "multiple-type" SLP condition reduction lacks
    handling EXTRACT_LAST reductions.

            PR tree-optimization/115537
            * tree-vect-loop.cc (vectorizable_reduction): Also reject
            SLP condition reductions of EXTRACT_LAST kind when multiple
            statement copies are involved.

            * gcc.dg/vect/pr115537.c: New testcase.

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

* [Bug tree-optimization/115537] [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
  2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-06-18 13:28 ` cvs-commit at gcc dot gnu.org
@ 2024-06-18 13:28 ` rguenth at gcc dot gnu.org
  2024-06-18 14:11 ` tnfchris at gcc dot gnu.org
  2024-06-18 15:29 ` rguenther at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-18 13:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug tree-optimization/115537] [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
  2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-06-18 13:28 ` rguenth at gcc dot gnu.org
@ 2024-06-18 14:11 ` tnfchris at gcc dot gnu.org
  2024-06-18 15:29 ` rguenther at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2024-06-18 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Thanks for the fix!

I think the testcase needs SVE enabled to ICE no?
shouldn't that be -mcpu=neoverse-v1 and not -mcpu=neoverse-n1?

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

* [Bug tree-optimization/115537] [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d
  2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-06-18 14:11 ` tnfchris at gcc dot gnu.org
@ 2024-06-18 15:29 ` rguenther at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: rguenther at suse dot de @ 2024-06-18 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> ---
> Am 18.06.2024 um 16:11 schrieb tnfchris at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115537
> 
> --- Comment #5 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
> Thanks for the fix!
> 
> I think the testcase needs SVE enabled to ICE no?
> shouldn't that be -mcpu=neoverse-v1 and not -mcpu=neoverse-n1?

I intended to copy from the PR options, in case I mistyped feel free to correct 

> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.

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

end of thread, other threads:[~2024-06-18 15:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-18 11:12 [Bug tree-optimization/115537] New: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d tnfchris at gcc dot gnu.org
2024-06-18 11:46 ` [Bug tree-optimization/115537] " rguenth at gcc dot gnu.org
2024-06-18 12:00 ` rguenth at gcc dot gnu.org
2024-06-18 13:28 ` cvs-commit at gcc dot gnu.org
2024-06-18 13:28 ` rguenth at gcc dot gnu.org
2024-06-18 14:11 ` tnfchris at gcc dot gnu.org
2024-06-18 15:29 ` rguenther at suse dot de

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