public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173
@ 2020-03-30  9:22 z.zhanghaijian at huawei dot com
  2020-03-30  9:23 ` [Bug tree-optimization/94398] " z.zhanghaijian at huawei dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: z.zhanghaijian at huawei dot com @ 2020-03-30  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94398
           Summary: ICE: in vectorizable_load, at tree-vect-stmts.c:9173
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: z.zhanghaijian at huawei dot com
                CC: rguenther at suse dot de
  Target Milestone: ---

test case: gcc/testsuite/gcc.dg/pr94269.c

Command line: aarch64-linux-gnu-gcc -S -O2 -fopt-info -march=armv8.2-a+sve
-msve-vector-bits=256 -ftree-loop-vectorize -funsafe-math-optimizations
-mstrict-align pr94269.c

pr94269.c:16:9: optimized: loop vectorized using 32 byte vectors
during GIMPLE pass: vect
pr94269.c: In function 'foo':
pr94269.c:5:1: internal compiler error: in vectorizable_load, at
tree-vect-stmts.c:9173
    5 | foo(long n, float *x, int inc_x,
      | ^~~
0x162fcc7 vectorizable_load
        ../../gcc-git/gcc/tree-vect-stmts.c:9173
0x1635173 vect_transform_stmt(_stmt_vec_info*, gimple_stmt_iterator*,
_slp_tree*, _slp_instance*)
        ../../gcc-git/gcc/tree-vect-stmts.c:11034
0x165a33f vect_transform_loop_stmt
        ../../gcc-git/gcc/tree-vect-loop.c:8307
0x165b5c3 vect_transform_loop(_loop_vec_info*, gimple*)
        ../../gcc-git/gcc/tree-vect-loop.c:8708
0x1689f07 try_vectorize_loop_1
        ../../gcc-git/gcc/tree-vectorizer.c:990
0x168a183 try_vectorize_loop
        ../../gcc-git/gcc/tree-vectorizer.c:1047
0x168a32f vectorize_loops()
        ../../gcc-git/gcc/tree-vectorizer.c:1127
0x14e55e3 execute
        ../../gcc-git/gcc/tree-ssa-loop.c:414
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

With -mstrict-align, aarch64_builtin_support_vector_misalignment will returns
false when misalignment factor is unknown at compile time.
Then vect_supportable_dr_alignment returns dr_unaligned_unsupported, which
triggers the ICE.

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

* [Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173
  2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
@ 2020-03-30  9:23 ` z.zhanghaijian at huawei dot com
  2020-03-30  9:31 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: z.zhanghaijian at huawei dot com @ 2020-03-30  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from z.zhanghaijian at huawei dot com <z.zhanghaijian at huawei dot com> ---
(gdb) bt
#0  aarch64_builtin_support_vector_misalignment (mode=E_VNx4SFmode,
type=0xffffb79ec2a0, misalignment=-1, is_packed=false)
    at ../../gcc-git/gcc/config/aarch64/aarch64.c:17510
#1  0x000000000220631c in vect_supportable_dr_alignment (dr_info=0x2ef3798,
check_aligned_accesses=false) at ../../gcc-git/gcc/tree-vect-data-refs.c:6618
#2  0x000000000162fc9c in vectorizable_load (stmt_info=0x2ef3770,
gsi=0xffffffffe0b0, vec_stmt=0xffffffffdde0, slp_node=0x0,
slp_node_instance=0x0,
    cost_vec=0x0) at ../../gcc-git/gcc/tree-vect-stmts.c:9172
#3  0x0000000001635174 in vect_transform_stmt (stmt_info=0x2ef3770,
gsi=0xffffffffe0b0, slp_node=0x0, slp_node_instance=0x0)
    at ../../gcc-git/gcc/tree-vect-stmts.c:11034
#4  0x000000000165a340 in vect_transform_loop_stmt (loop_vinfo=0x2ed0ad0,
stmt_info=0x2ef3770, gsi=0xffffffffe0b0, seen_store=0xffffffffe0a8)
    at ../../gcc-git/gcc/tree-vect-loop.c:8307
#5  0x000000000165b5c4 in vect_transform_loop (loop_vinfo=0x2ed0ad0,
loop_vectorized_call=0x0) at ../../gcc-git/gcc/tree-vect-loop.c:8708
#6  0x0000000001689f08 in try_vectorize_loop_1
(simduid_to_vf_htab=@0xffffffffed68: 0x0, num_vectorized_loops=0xffffffffed7c,
loop=0xffffb7820000,
    loop_vectorized_call=0x0, loop_dist_alias_call=0x0) at
../../gcc-git/gcc/tree-vectorizer.c:990
#7  0x000000000168a184 in try_vectorize_loop
(simduid_to_vf_htab=@0xffffffffed68: 0x0, num_vectorized_loops=0xffffffffed7c,
loop=0xffffb7820000)
    at ../../gcc-git/gcc/tree-vectorizer.c:1047
#8  0x000000000168a330 in vectorize_loops () at
../../gcc-git/gcc/tree-vectorizer.c:1127
#9  0x00000000014e55e4 in (anonymous namespace)::pass_vectorize::execute
(this=0x2d6f860, fun=0xffffb7817000) at ../../gcc-git/gcc/tree-ssa-loop.c:414
#10 0x000000000113dec0 in execute_one_pass (pass=0x2d6f860) at
../../gcc-git/gcc/passes.c:2502
#11 0x000000000113e284 in execute_pass_list_1 (pass=0x2d6f860) at
../../gcc-git/gcc/passes.c:2590
#12 0x000000000113e2c0 in execute_pass_list_1 (pass=0x2d6f070) at
../../gcc-git/gcc/passes.c:2591
#13 0x000000000113e2c0 in execute_pass_list_1 (pass=0x2d6dd00) at
../../gcc-git/gcc/passes.c:2591
#14 0x000000000113e32c in execute_pass_list (fn=0xffffb7817000, pass=0x2d6db20)
at ../../gcc-git/gcc/passes.c:2601
#15 0x0000000000be2f50 in cgraph_node::expand (this=0xffffb79dc870) at
../../gcc-git/gcc/cgraphunit.c:2299
#16 0x0000000000be3814 in expand_all_functions () at
../../gcc-git/gcc/cgraphunit.c:2470
#17 0x0000000000be45c4 in symbol_table::compile (this=0xffffb79ce000) at
../../gcc-git/gcc/cgraphunit.c:2820
#18 0x0000000000be4b14 in symbol_table::finalize_compilation_unit
(this=0xffffb79ce000) at ../../gcc-git/gcc/cgraphunit.c:3000
#19 0x000000000129f7dc in compile_file () at ../../gcc-git/gcc/toplev.c:483
#20 0x00000000012a3a14 in do_compile () at ../../gcc-git/gcc/toplev.c:2273
#21 0x00000000012a3de0 in toplev::main (this=0xfffffffff148, argc=21,
argv=0xfffffffff298) at ../../gcc-git/gcc/toplev.c:2412
#22 0x000000000224a038 in main (argc=21, argv=0xfffffffff298) 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.yang@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 <gcall *> (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 <gcall *> (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)
     {

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

* [Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173
  2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
  2020-03-30  9:23 ` [Bug tree-optimization/94398] " z.zhanghaijian at huawei dot com
@ 2020-03-30  9:31 ` rguenth at gcc dot gnu.org
  2020-03-30  9:55 ` rsandifo at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-30  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> 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 <rguenth at gcc dot gnu.org> ---
But the ICE happens because the result from the function at transform time does
not match that at analysis time.

Richard?

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

* [Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173
  2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
  2020-03-30  9:23 ` [Bug tree-optimization/94398] " z.zhanghaijian at huawei dot com
  2020-03-30  9:31 ` rguenth at gcc dot gnu.org
@ 2020-03-30  9:55 ` rsandifo at gcc dot gnu.org
  2020-03-30  9:56 ` rsandifo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2020-03-30  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from rsandifo at gcc dot gnu.org <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.

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

* [Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173
  2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
                   ` (2 preceding siblings ...)
  2020-03-30  9:55 ` rsandifo at gcc dot gnu.org
@ 2020-03-30  9:56 ` rsandifo at gcc dot gnu.org
  2020-03-31 14:14 ` cvs-commit at gcc dot gnu.org
  2021-11-29  8:45 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2020-03-30  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

rsandifo at gcc dot gnu.org <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 <rsandifo at gcc dot gnu.org> ---
(In reply to rsandifo@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 :-)

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

* [Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173
  2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
                   ` (3 preceding siblings ...)
  2020-03-30  9:56 ` rsandifo at gcc dot gnu.org
@ 2020-03-31 14:14 ` cvs-commit at gcc dot gnu.org
  2021-11-29  8:45 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-03-31 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

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

commit r10-7481-gf14b41d27124601284347a10d496362c8b4b8e1c
Author: Felix Yang <felix.yang@huawei.com>
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  <felix.yang@huawei.com>

    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.

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

* [Bug tree-optimization/94398] ICE: in vectorizable_load, at tree-vect-stmts.c:9173
  2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
                   ` (4 preceding siblings ...)
  2020-03-31 14:14 ` cvs-commit at gcc dot gnu.org
@ 2021-11-29  8:45 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-29  8:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-11-29  8:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30  9:22 [Bug tree-optimization/94398] New: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 z.zhanghaijian at huawei dot com
2020-03-30  9:23 ` [Bug tree-optimization/94398] " z.zhanghaijian at huawei dot com
2020-03-30  9:31 ` rguenth at gcc dot gnu.org
2020-03-30  9:55 ` rsandifo at gcc dot gnu.org
2020-03-30  9:56 ` rsandifo at gcc dot gnu.org
2020-03-31 14:14 ` cvs-commit at gcc dot gnu.org
2021-11-29  8:45 ` pinskia at gcc dot gnu.org

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