[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-22 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

Robin Dapp  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #8 from Robin Dapp  ---
Fixed.

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
So, can this be closed as fixed?

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

--- Comment #6 from CVS Commits  ---
The master branch has been updated by Robin Dapp :

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

commit r14-5322-gd7b971cf61ae0091dbc777c9aa056e6f1293da2f
Author: Robin Dapp 
Date:   Fri Nov 10 08:56:18 2023 +0100

vect: Look through pattern stmt in fold_left_reduction.

It appears as if we "look through" a statement pattern in
vect_finish_replace_stmt but not before when we replace the newly
created vector statement's lhs.  Then the lhs is the statement pattern's
lhs while in vect_finish_replace_stmt we assert that it's from the
statement the pattern replaced.

This patch uses vect_orig_stmt on the scalar destination's definition so
the replaced statement is used everywhere.

gcc/ChangeLog:

PR tree-optimization/112464

* tree-vect-loop.cc (vectorize_fold_left_reduction): Use
vect_orig_stmt on scalar_dest_def_info.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr112464.c: New test.

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-10 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

--- Comment #5 from Richard Biener  ---
(In reply to Robin Dapp from comment #4)
> Is there another way to make it more robust?
> 
> Or does the existing
> 
> void
> vect_finish_replace_stmt (vec_info *vinfo,
> stmt_vec_info stmt_info, gimple *vec_stmt)
> {
>   gimple *scalar_stmt = vect_orig_stmt (stmt_info)->stmt;
> 
> have the same problem?

Well, yeah, it also implicitly assumes that.  I couldn't come up with
the "correct" assert quickly, so I didn't suggest any.  That is, just
go with your patch.

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-10 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

--- Comment #4 from Robin Dapp  ---
Is there another way to make it more robust?

Or does the existing

void
vect_finish_replace_stmt (vec_info *vinfo,
  stmt_vec_info stmt_info, gimple *vec_stmt)
{
  gimple *scalar_stmt = vect_orig_stmt (stmt_info)->stmt;

have the same problem?

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-10 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2023-11-10
 Ever confirmed|0   |1

--- Comment #3 from Richard Biener  ---
(In reply to Robin Dapp from comment #2)
> I tested
> 
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index a544bc9b059..257fd40793e 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -7084,7 +7084,7 @@ vectorize_fold_left_reduction (loop_vec_info
> loop_vinfo,
>  opmask, _opmask);
>  }
>  
> -  gimple *sdef = scalar_dest_def_info->stmt;
> +  gimple *sdef = vect_orig_stmt (scalar_dest_def_info)->stmt;
> 
> overnight on x86 and aarch64.  This seems to help for the reduced testcase.
> 
> It appears as if we "look through" a statement pattern in
> vect_finish_replace_stmt but not before when we replace the newly created
> vector statement's lhs.  Then the lhs is the statement pattern's lhs while
> in vect_finish_replace_stmt we assert that it's from the statement the
> pattern replaced.

Hmm, that will only work if the orig stmt is the root of the pattern
sequence.  But otherwise it looks correct to me.

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-09 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

--- Comment #2 from Robin Dapp  ---
I tested

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index a544bc9b059..257fd40793e 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7084,7 +7084,7 @@ vectorize_fold_left_reduction (loop_vec_info loop_vinfo,
 opmask, _opmask);
 }

-  gimple *sdef = scalar_dest_def_info->stmt;
+  gimple *sdef = vect_orig_stmt (scalar_dest_def_info)->stmt;

overnight on x86 and aarch64.  This seems to help for the reduced testcase.

It appears as if we "look through" a statement pattern in
vect_finish_replace_stmt but not before when we replace the newly created
vector statement's lhs.  Then the lhs is the statement pattern's lhs while in
vect_finish_replace_stmt we assert that it's from the statement the pattern
replaced.

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-09 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

--- Comment #1 from Robin Dapp  ---
We fail at:

void
vect_finish_replace_stmt (vec_info *vinfo,
  stmt_vec_info stmt_info, gimple *vec_stmt)
{
  gimple *scalar_stmt = vect_orig_stmt (stmt_info)->stmt;
  gcc_assert (gimple_get_lhs (scalar_stmt) == gimple_get_lhs (vec_stmt));

where

scalar_stmt = _ifc__40 = .COND_ADD (_22, err_lsm.9_10, 1, err_lsm.9_10);
and
patt_7 = stmp_patt_7.23_123 + stmp_patt_7.23_124;

It happens when we expand the reduction into separate unconditional statements.

[Bug tree-optimization/112464] [14 Regression] ICE avx512 with -ftrapv since r14-5076

2023-11-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |14.0