[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2024-01-09 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

Tamar Christina  changed:

   What|Removed |Added

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

--- Comment #14 from Tamar Christina  ---
Fixed, thanks for the report.

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2024-01-09 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #13 from GCC Commits  ---
The master branch has been updated by Tamar Christina :

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

commit r14-7036-gcbf569486b2decbde0308f9f4d0f0837e4cfefd9
Author: Tamar Christina 
Date:   Tue Jan 9 11:16:16 2024 +

middle-end: rejects loops with nonlinear inductions and early breaks
[PR113163]

We can't support nonlinear inductions other than neg when vectorizing
early breaks and iteration count is known.

For early break we currently require a peeled epilog but in these cases
we can't compute the remaining values.

gcc/ChangeLog:

PR middle-end/113163
* tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p):
Reject non-linear inductions that aren't supported.

gcc/testsuite/ChangeLog:

PR middle-end/113163
* gcc.target/gcn/pr113163.c: New test.

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2024-01-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |14.0

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2024-01-02 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #12 from Tamar Christina  ---
(In reply to Andrew Stubbs from comment #11)
> (In reply to Tamar Christina from comment #7)
> > This seems to happen because the vectorizer decides to use partial vectors
> > to vectorize the loop and the target picks a nonlinear induction step which
> > we can't support for early breaks.
> 
> In which hook is this selected?
> 
> I'm not aware of this being a deliberate choice we made...

I haven't looked into why on the target we get a nonlinear induction (mostly
because I don't know much about the target). I however wasn't able to reproduce
it on SVE and x86_64 even when forcing partial vectors.

So I guess it's more accurate to say "something about the target" is making the
vectorizer pick a nonlinear induction.  most likely missing support for
something.

Note that the testcase does work if partial vectors is turned off. So It should
work fine if the vectorizer retries without partial vectors.

waiting for Richi to come back from holiday to review the patch and should be
fixed.

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2024-01-02 Thread ams at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

Andrew Stubbs  changed:

   What|Removed |Added

 CC||ams at gcc dot gnu.org

--- Comment #11 from Andrew Stubbs  ---
(In reply to Tamar Christina from comment #7)
> This seems to happen because the vectorizer decides to use partial vectors
> to vectorize the loop and the target picks a nonlinear induction step which
> we can't support for early breaks.

In which hook is this selected?

I'm not aware of this being a deliberate choice we made...

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-29 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #10 from Tamar Christina  ---
Patch submitted

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-29 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

Tamar Christina  changed:

   What|Removed |Added

 CC||doko at gcc dot gnu.org

--- Comment #9 from Tamar Christina  ---
*** Bug 113169 has been marked as a duplicate of this bug. ***

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #8 from Tamar Christina  ---
Created attachment 56959
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56959=edit
nonlinear IV

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

Tamar Christina  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
   Priority|P3  |P1
   Last reconfirmed||2023-12-28
   Assignee|unassigned at gcc dot gnu.org  |tnfchris at gcc dot 
gnu.org

--- Comment #7 from Tamar Christina  ---
ok, managed to reproduce using a cross cc1.

This seems to happen because the vectorizer decides to use partial vectors to
vectorize the loop and the target picks a nonlinear induction step which we
can't support for early breaks.

The attached patch fixes it by rejecting these kind of inductions when partial
vectors are forced.

I'll submit the patch for when maintainers are back from holidays.

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #6 from Tobias Burnus  ---
and for that condition, we have:

3375  if (!integer_onep (*step_vector))
(gdb) p debug_tree(*step_vector)
  constant 8>

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #5 from Tobias Burnus  ---
While higher at the call stack:

#3  0x0148714f in vect_transform_loop
(loop_vinfo=loop_vinfo@entry=0x350f2a0,
loop_vectorized_call=loop_vectorized_call@entry=0x0)
at src/gcc-mainline/gcc/tree-vect-loop.cc:11911
11911 epilogue = vect_do_peeling (loop_vinfo, niters, nitersm1,
_vector,

(gdb) p debug_tree(niters)
  constant 6>


One level down:

#2  0x01498154 in vect_do_peeling
(loop_vinfo=loop_vinfo@entry=0x350f2a0, niters=,
niters@entry=0x77bb2030, 
nitersm1=nitersm1@entry=0x77bb2c78,
niters_vector=niters_vector@entry=0x7fffda60,
step_vector=step_vector@entry=0x7fffda68, 
niters_vector_mult_vf_var=niters_vector_mult_vf_var@entry=0x7fffda70,
th=, check_profitability=, 
niters_no_overflow=, advance=)
at src/gcc-mainline/gcc/tree-vect-loop-manip.cc:3399
3399vect_update_ivs_after_vectorizer (loop_vinfo,
niters_vector_mult_vf,

where niters_vector_mult_vf is ssa_name that fails in the assert.


The variable seems to be generated a few lines up in the same function (line
3375 and following):

  if (!integer_onep (*step_vector))
{
  /* On exit from the loop we will have an easy way of calcalating
 NITERS_VECTOR / STEP * STEP.  Install a dummy definition
 until then.  */
  niters_vector_mult_vf = make_ssa_name (TREE_TYPE (*niters_vector));
  SSA_NAME_DEF_STMT (niters_vector_mult_vf) = gimple_build_nop ();
  *niters_vector_mult_vf_var = niters_vector_mult_vf;
}
  else
vect_gen_vector_loop_niters_mult_vf (loop_vinfo, *niters_vector,
 _vector_mult_vf);

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #4 from Tamar Christina  ---
Hmm so can't seem to reproduce it with x86_64 or aarch64.

let me build a --target=amdgcn-amdhsa

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #3 from Tamar Christina  ---
Thanks, taking a look.

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

--- Comment #2 from Tobias Burnus  ---
Created attachment 56958
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56958=edit
Reduced testcase (

$ amdgcn-amdhsa-gcc -g -O2 inp5.i -march=gfx900

during GIMPLE pass: vect
inp5.i: In function '_l64a_r':
inp5.i:4:1: internal compiler error: in vect_peel_nonlinear_iv_init, at
tree-vect-loop.cc:9420
4 | _l64a_r (struct _reent *rptr,
  | ^~~
0x94cc17 vect_peel_nonlinear_iv_init(gimple**, tree_node*, tree_node*,
tree_node*, vect_induction_op_type)
   
/net/build5-fossa-cs/scratch/tburnus/fsf.mainline.x86_64-linux-gnu-amdgcn/src/gcc-mainline/gcc/tree-vect-loop.cc:9420
0x148bb04 vect_update_ivs_after_vectorizer
src/gcc-mainline/gcc/tree-vect-loop-manip.cc:2267
0x1498153 vect_do_peeling(_loop_vec_info*, tree_node*, tree_node*, tree_node**,
tree_node**, tree_node**, int, bool, bool, tree_node**)
src/gcc-mainline/gcc/tree-vect-loop-manip.cc:3399
0x148714e vect_transform_loop(_loop_vec_info*, gimple*)
src/gcc-mainline/gcc/tree-vect-loop.cc:11911
0x14c9544 vect_transform_loops
src/gcc-mainline/gcc/tree-vectorizer.cc:1006
0x14c9bc3 try_vectorize_loop_1
src/gcc-mainline/gcc/tree-vectorizer.cc:1152
0x14c9bc3 try_vectorize_loop
src/gcc-mainline/gcc/tree-vectorizer.cc:1182
0x14ca224 execute
src/gcc-mainline/gcc/tree-vectorizer.cc:1298

 * * *

Breakpoint 1, vect_peel_nonlinear_iv_init (stmts=0x7fffd698,
init_expr=0x77a56948, skip_niters=0x77bb8798, 
step_expr=0x77a64ba0, induction_type=vect_step_op_shr)
at src/gcc-mainline/gcc/tree-vect-loop.cc:9420
9420  gcc_assert (TREE_CODE (skip_niters) == INTEGER_CST);

(gdb) p debug_tree(skip_niters)
 
unit-size 
align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x77b5e3f0 precision:32 min  max >

def_stmt GIMPLE_NOP
version:54>
$2 = void

[Bug middle-end/113163] [14 Regression][GCN] ICE in vect_peel_nonlinear_iv_init, at tree-vect-loop.cc:9420

2023-12-28 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113163

Tamar Christina  changed:

   What|Removed |Added

 CC||tnfchris at gcc dot gnu.org

--- Comment #1 from Tamar Christina  ---
Hi,

This does not contain enough information for me to try to reproduce the issue.

Can you give me the full target triple, compile flag and how the compiler was
configured?

A reproducer would be helpful too.