[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-21 Thread thiago.bauermann at linaro dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

--- Comment #15 from Thiago Jung Bauermann  
---
Thanks! I confirmed that I can't reproduce the problem anymore in trunk.

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-21 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

Richard Biener  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #14 from Richard Biener  ---
Fixed.

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-21 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

--- Comment #13 from CVS Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:9a8782e63790842d1bfa03e12eecf73c4aaeb1f8

commit r14-2697-g9a8782e63790842d1bfa03e12eecf73c4aaeb1f8
Author: Richard Biener 
Date:   Thu Jul 20 13:09:17 2023 +0200

tree-optimization/110742 - fix latent issue with permuting existing vectors

When we materialize a layout we push edge permutes to constant/external
defs without checking we can actually do so.  For externals defined
by vector stmts rather than scalar components we can't.

PR tree-optimization/110742
* tree-vect-slp.cc
(vect_optimize_slp_pass::get_result_with_layout):
Do not materialize an edge permutation in an external node with
vector defs.
(vect_slp_analyze_node_operations_1): Guard purely internal
nodes better.

* g++.dg/torture/pr110742.C: New testcase.

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-20 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

Richard Biener  changed:

   What|Removed |Added

 CC||rsandifo at gcc dot gnu.org

--- Comment #12 from Richard Biener  ---
So we have those external def nodes for existing vectors in the IL.  Obviously
we cannot change the layout of those - where can we specify that?  I
see is_compatible_layout or change_layout_cost.  But start_choosing_layouts
already assigns layout 0 to it where I thought this would effectively
prevent changes?

Oddly in forward_pass we first have partition.layout == 0 && layout_i == 0
but still do stuff.

$38 = 0x3d8f690 = {{node_begin = 0, node_end = 1, layout = 0, in_degree = 0,
out_degree = 1}, {
node_begin = 1, node_end = 2, layout = 1, in_degree = 1, out_degree = 0},
{node_begin = 2, 
node_end = 3, layout = 2, in_degree = 0, out_degree = 0}}

later we ask if changing layout from 0 to 1 is OK.

I suppose the bug is in get_result_with_layout itself which assumes
changing vect_constant_def/vect_external_def is fine and thus pushes
the edge permute to the node?

I wonder if I fix that say with the following, if I also need to adjust
costs somewhere?

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 693621ca990..1d79c77e8ce 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -5198,7 +5198,10 @@ vect_optimize_slp_pass::get_result_with_layout (slp_tree
node,
 return result;

   if (SLP_TREE_DEF_TYPE (node) == vect_constant_def
-  || SLP_TREE_DEF_TYPE (node) == vect_external_def)
+  || (SLP_TREE_DEF_TYPE (node) == vect_external_def
+ && (to_layout_i == 0
+ /* We can't permute vector defs.  */
+ || SLP_TREE_VEC_DEFS (node).is_empty (
 {
   /* If the vector is uniform or unchanged, there's nothing to do.  */
   if (to_layout_i == 0 || vect_slp_tree_uniform_p (node))

I'll also note that we do

  /* Handle externals and constants optimistically throughout.
 But treat existing vectors as fixed since we do not handle
 permuting them.  */
  unsigned int node_i = m_partitioned_nodes[rpo_i];
  auto  = m_vertices[node_i];
  if ((SLP_TREE_DEF_TYPE (vertex.node) == vect_external_def
   && !SLP_TREE_VEC_DEFS (vertex.node).exists ())
  || SLP_TREE_DEF_TYPE (vertex.node) == vect_constant_def)
vertex.partition = -1;

in create_partitions ().

I'm testing the above change now.

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-20 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

Richard Biener  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #11 from Richard Biener  ---
Huh.

t.ii:33:6: note: node (external) 0x3c91c88 (max_nunits=1, refcnt=2) vector(2)
long unsigned int
t.ii:33:6: note:{ }

and neither vec_stmts nor ->lanes.  Ah.  Looks like a latent issue in
vect_optimize_slp_pass::get_result_with_layout.

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-19 Thread thiago.bauermann at linaro dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

--- Comment #10 from Thiago Jung Bauermann  
---
Thank you very much for digging into this!

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-19 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

--- Comment #9 from Andrew Pinski  ---
Backtrace and some debug:
Program received signal SIGFPE, Arithmetic exception.
0x01d00dd2 in multiple_p (a=2, b=0) at
../../gcc/poly-int.h:2123
2123  return a % b == 0;
(gdb) bt
#0  0x01d00dd2 in multiple_p (a=2, b=0) at
../../gcc/poly-int.h:2123
#1  0x01cf0c61 in vect_prologue_cost_for_slp (node=0x3a6a098,
cost_vec=0x7fffceb0) at ../../gcc/tree-vect-slp.cc:6088

(gdb) up
#1  0x01cf0c61 in vect_prologue_cost_for_slp (node=0x3a6a098,
cost_vec=0x7fffceb0) at ../../gcc/tree-vect-slp.cc:6088
6088  && ! multiple_p (const_nunits, group_size))
(gdb) p group_size
$2 = 0
(gdb) p const_nunits
$3 = 2

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-19 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

Andrew Pinski  changed:

   What|Removed |Added

  Known to fail||14.0
  Known to work||13.1.0

--- Comment #8 from Andrew Pinski  ---
Note my reduced testcase worked with GCC 13.1.0 so this is still a GCC 14
regression .

[Bug tree-optimization/110742] [14 Regression] cc1plus ICE "Floating point exception" during SLP and profiled bootstrap

2023-07-19 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110742

--- Comment #7 from Andrew Pinski  ---
Removed reference to g:08b99fe8ad6 in the summary since the ICE is in SLP and
just happens to be compiling the code that was changed with g:08b99fe8ad6 .