[Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173

2021-11-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94398

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED
   Target Milestone|--- |10.0
   Keywords||ice-on-valid-code

--- Comment #6 from Andrew Pinski  ---
Fixed.

[Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173

2020-03-31 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94398

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Richard Sandiford :

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

commit r10-7481-gf14b41d27124601284347a10d496362c8b4b8e1c
Author: Felix Yang 
Date:   Tue Mar 31 16:41:56 2020 +0800

vect: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 [PR94398]

In the testcase for PR94398, we're trying to compute:

  alignment_support_scheme
= vect_supportable_dr_alignment (first_dr_info, false);
  gcc_assert (alignment_support_scheme);

even for VMAT_GATHER_SCATTER, which always accesses individual elements.
Here we should set alignment_support_scheme to dr_unaligned_supported
the gather/scatter case instead of calling vect_supportable_dr_alignment.

2020-03-31  Felix Yang  

gcc/
PR tree-optimization/94398
* tree-vect-stmts.c (vectorizable_store): Instead of calling
vect_supportable_dr_alignment, set alignment_support_scheme to
dr_unaligned_supported for gather-scatter accesses.
(vectorizable_load): Likewise.

gcc/testsuite/
PR tree-optimization/94398
* gcc.target/aarch64/pr94398.c: New test.

[Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173

2020-03-30 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94398

rsandifo at gcc dot gnu.org  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2020-03-30
 Status|UNCONFIRMED |NEW

--- Comment #4 from rsandifo at gcc dot gnu.org  
---
(In reply to rsand...@gcc.gnu.org from comment #3)
> (In reply to Richard Biener from comment #2)
> > But the ICE happens because the result from the function at transform time
> > does not match that at analysis time.
> > 
> > Richard?
> 
> Looks like we're trying to compute:
> 
>   alignment_support_scheme
> = vect_supportable_dr_alignment (first_dr_info, false);
>   gcc_assert (alignment_support_scheme);
> 
> even for VMAT_GATHER_SCATTER, which always accesses individual
> elements.  Guess we should set alignment_support_scheme to
> dr_unaligned_supported instead of calling
> vect_supportable_dr_alignment.

...in the gather/scatter case only, of course :-)

[Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173

2020-03-30 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94398

--- Comment #3 from rsandifo at gcc dot gnu.org  
---
(In reply to Richard Biener from comment #2)
> But the ICE happens because the result from the function at transform time
> does not match that at analysis time.
> 
> Richard?

Looks like we're trying to compute:

  alignment_support_scheme
= vect_supportable_dr_alignment (first_dr_info, false);
  gcc_assert (alignment_support_scheme);

even for VMAT_GATHER_SCATTER, which always accesses individual
elements.  Guess we should set alignment_support_scheme to
dr_unaligned_supported instead of calling
vect_supportable_dr_alignment.

The target hook is probably incorrect for SVE + -mstrict-align.

[Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173

2020-03-30 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94398

Richard Biener  changed:

   What|Removed |Added

 Target||aarch64
 CC|rguenther at suse dot de   |rguenth at gcc dot 
gnu.org,
   ||rsandifo at gcc dot gnu.org

--- Comment #2 from Richard Biener  ---
But the ICE happens because the result from the function at transform time does
not match that at analysis time.

Richard?

[Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173

2020-03-30 Thread z.zhanghaijian at huawei dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94398

--- Comment #1 from z.zhanghaijian at huawei dot com  ---
(gdb) bt
#0  aarch64_builtin_support_vector_misalignment (mode=E_VNx4SFmode,
type=0xb79ec2a0, misalignment=-1, is_packed=false)
at ../../gcc-git/gcc/config/aarch64/aarch64.c:17510
#1  0x0220631c in vect_supportable_dr_alignment (dr_info=0x2ef3798,
check_aligned_accesses=false) at ../../gcc-git/gcc/tree-vect-data-refs.c:6618
#2  0x0162fc9c in vectorizable_load (stmt_info=0x2ef3770,
gsi=0xe0b0, vec_stmt=0xdde0, slp_node=0x0,
slp_node_instance=0x0,
cost_vec=0x0) at ../../gcc-git/gcc/tree-vect-stmts.c:9172
#3  0x01635174 in vect_transform_stmt (stmt_info=0x2ef3770,
gsi=0xe0b0, slp_node=0x0, slp_node_instance=0x0)
at ../../gcc-git/gcc/tree-vect-stmts.c:11034
#4  0x0165a340 in vect_transform_loop_stmt (loop_vinfo=0x2ed0ad0,
stmt_info=0x2ef3770, gsi=0xe0b0, seen_store=0xe0a8)
at ../../gcc-git/gcc/tree-vect-loop.c:8307
#5  0x0165b5c4 in vect_transform_loop (loop_vinfo=0x2ed0ad0,
loop_vectorized_call=0x0) at ../../gcc-git/gcc/tree-vect-loop.c:8708
#6  0x01689f08 in try_vectorize_loop_1
(simduid_to_vf_htab=@0xed68: 0x0, num_vectorized_loops=0xed7c,
loop=0xb782,
loop_vectorized_call=0x0, loop_dist_alias_call=0x0) at
../../gcc-git/gcc/tree-vectorizer.c:990
#7  0x0168a184 in try_vectorize_loop
(simduid_to_vf_htab=@0xed68: 0x0, num_vectorized_loops=0xed7c,
loop=0xb782)
at ../../gcc-git/gcc/tree-vectorizer.c:1047
#8  0x0168a330 in vectorize_loops () at
../../gcc-git/gcc/tree-vectorizer.c:1127
#9  0x014e55e4 in (anonymous namespace)::pass_vectorize::execute
(this=0x2d6f860, fun=0xb7817000) at ../../gcc-git/gcc/tree-ssa-loop.c:414
#10 0x0113dec0 in execute_one_pass (pass=0x2d6f860) at
../../gcc-git/gcc/passes.c:2502
#11 0x0113e284 in execute_pass_list_1 (pass=0x2d6f860) at
../../gcc-git/gcc/passes.c:2590
#12 0x0113e2c0 in execute_pass_list_1 (pass=0x2d6f070) at
../../gcc-git/gcc/passes.c:2591
#13 0x0113e2c0 in execute_pass_list_1 (pass=0x2d6dd00) at
../../gcc-git/gcc/passes.c:2591
#14 0x0113e32c in execute_pass_list (fn=0xb7817000, pass=0x2d6db20)
at ../../gcc-git/gcc/passes.c:2601
#15 0x00be2f50 in cgraph_node::expand (this=0xb79dc870) at
../../gcc-git/gcc/cgraphunit.c:2299
#16 0x00be3814 in expand_all_functions () at
../../gcc-git/gcc/cgraphunit.c:2470
#17 0x00be45c4 in symbol_table::compile (this=0xb79ce000) at
../../gcc-git/gcc/cgraphunit.c:2820
#18 0x00be4b14 in symbol_table::finalize_compilation_unit
(this=0xb79ce000) at ../../gcc-git/gcc/cgraphunit.c:3000
#19 0x0129f7dc in compile_file () at ../../gcc-git/gcc/toplev.c:483
#20 0x012a3a14 in do_compile () at ../../gcc-git/gcc/toplev.c:2273
#21 0x012a3de0 in toplev::main (this=0xf148, argc=21,
argv=0xf298) at ../../gcc-git/gcc/toplev.c:2412
#22 0x0224a038 in main (argc=21, argv=0xf298) at
../../gcc-git/gcc/main.c:39
(gdb) p misalignment
$3 = -1
(gdb) p mode
$4 = E_VNx4SFmode

vect_supportable_dr_alignment is expected to return either dr_aligned or
dr_unaligned_supported for masked operations. But it seems that this function
only catches internal_fn IFN_MASK_LOAD & IFN_MASK_STORE.
We are emitting a mask gather load here for this test case.  As backends have
their own vector misalignment support policy, I am supposing this should be
better handled in the auto-vect shared code.

Proposed fix by felix.y...@huawei.com:
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 0192aa6..67d3345 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -6509,11 +6509,26 @@ vect_supportable_dr_alignment (dr_vec_info *dr_info,

   /* For now assume all conditional loads/stores support unaligned
  access without any special code.  */
-  if (gcall *stmt = dyn_cast  (stmt_info->stmt))
-if (gimple_call_internal_p (stmt)
-   && (gimple_call_internal_fn (stmt) == IFN_MASK_LOAD
-   || gimple_call_internal_fn (stmt) == IFN_MASK_STORE))
-  return dr_unaligned_supported;
+  gcall *call = dyn_cast  (stmt_info->stmt);
+  if (call && gimple_call_internal_p (call))
+{
+  internal_fn ifn = gimple_call_internal_fn (call);
+  switch (ifn)
+   {
+ case IFN_MASK_LOAD:
+ case IFN_MASK_LOAD_LANES:
+ case IFN_MASK_GATHER_LOAD:
+ case IFN_MASK_STORE:
+ case IFN_MASK_STORE_LANES:
+ case IFN_MASK_SCATTER_STORE:
+   return dr_unaligned_supported;
+ default:
+   break;
+   }
+}
+
+  if (loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
+return dr_unaligned_supported;

   if (loop_vinfo)
 {