public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113172] New: ice in move_early_exit_stmts
@ 2023-12-29 19:14 dcb314 at hotmail dot com
  2023-12-29 19:15 ` [Bug middle-end/113172] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dcb314 at hotmail dot com @ 2023-12-29 19:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113172
           Summary: ice in move_early_exit_stmts
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For this C code:

int tswchp_2;
short cpy_buf[8];
void ts_endcmd() {
  int i = 0;
  for (; i < 8 && i < tswchp_2; i++)
    cpy_buf[i] = i;
}

compiled by recent gcc trunk, does this:

cvise $ ~/gcc/results/bin/gcc -c -O3  bug994.c
cvise $ ~/gcc/results/bin/gcc -c -O3 -march=znver3 bug994.c
during GIMPLE pass: vect
bug994.c: In function ‘ts_endcmd’:
bug994.c:3:6: internal compiler error: Segmentation fault
    3 | void ts_endcmd() {
      |      ^~~~~~~~~
0xeeade9 crash_signal(int)
        ../../trunk.20210101/gcc/toplev.cc:316
0x11a8e63 gsi_prev(gimple_stmt_iterator*)
        ../../trunk.20210101/gcc/gimple-iterator.h:236
0x11a8e63 move_early_exit_stmts(_loop_vec_info*)
        ../../trunk.20210101/gcc/tree-vect-loop.cc:11807

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

* [Bug middle-end/113172] [14 Regression] ice in move_early_exit_stmts
  2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
@ 2023-12-29 19:15 ` pinskia at gcc dot gnu.org
  2023-12-29 20:34 ` tnfchris at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-29 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
          Component|c                           |middle-end
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |14.0
            Summary|ice in                      |[14 Regression] ice in
                   |move_early_exit_stmts       |move_early_exit_stmts

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

* [Bug middle-end/113172] [14 Regression] ice in move_early_exit_stmts
  2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
  2023-12-29 19:15 ` [Bug middle-end/113172] [14 Regression] " pinskia at gcc dot gnu.org
@ 2023-12-29 20:34 ` tnfchris at gcc dot gnu.org
  2023-12-29 21:06 ` tnfchris at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2023-12-29 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-12-29
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |tnfchris at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=113137

--- Comment #1 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Thanks for the report, fixed by patch for #113137 and now correctly vectorizes

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

* [Bug middle-end/113172] [14 Regression] ice in move_early_exit_stmts
  2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
  2023-12-29 19:15 ` [Bug middle-end/113172] [14 Regression] " pinskia at gcc dot gnu.org
  2023-12-29 20:34 ` tnfchris at gcc dot gnu.org
@ 2023-12-29 21:06 ` tnfchris at gcc dot gnu.org
  2024-01-10 13:27 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2023-12-29 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Patch submitted

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

* [Bug middle-end/113172] [14 Regression] ice in move_early_exit_stmts
  2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2023-12-29 21:06 ` tnfchris at gcc dot gnu.org
@ 2024-01-10 13:27 ` rguenth at gcc dot gnu.org
  2024-01-12 15:32 ` cvs-commit at gcc dot gnu.org
  2024-01-12 15:35 ` tnfchris at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-10 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug middle-end/113172] [14 Regression] ice in move_early_exit_stmts
  2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2024-01-10 13:27 ` rguenth at gcc dot gnu.org
@ 2024-01-12 15:32 ` cvs-commit at gcc dot gnu.org
  2024-01-12 15:35 ` tnfchris at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-12 15:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <tnfchris@gcc.gnu.org>:

https://gcc.gnu.org/g:411de96dbf2bdafc7a90ebbfc63e68afd6388d29

commit r14-7195-g411de96dbf2bdafc7a90ebbfc63e68afd6388d29
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Fri Jan 12 15:25:34 2024 +0000

    middle-end: maintain LCSSA form when peeled vector iterations have virtual
operands

    This patch fixes several interconnected issues.

    1. When picking an exit we wanted to check for niter_desc.may_be_zero not
true.
       i.e. we want to pick an exit which we know will iterate at least once.
       However niter_desc.may_be_zero is not a boolean.  It is a tree that
encodes
       a boolean value.  !niter_desc.may_be_zero is just checking if we have
some
       information, not what the information is.  This leads us to pick a more
       difficult to vectorize exit more often than we should.

    2. Because we had this bug, we used to pick an alternative exit much more
ofthen
       which showed one issue, when the loop accesses memory and we "invert it"
we
       would corrupt the VUSE chain.  This is because on an peeled vector
iteration
       every exit restarts the loop (i.e. they're all early) BUT since we may
have
       performed a store, the vUSE would need to be updated.  This version
maintains
       virtual PHIs correctly in these cases.   Note that we can't simply
remove all
       of them and recreate them because we need the PHI nodes still in the
right
       order for if skip_vector.

    3. Since we're moving the stores to a safe location I don't think we
actually
       need to analyze whether the store is in range of the memref,  because if
we
       ever get there, we know that the loads must be in range, and if the
loads are
       in range and we get to the store we know the early breaks were not taken
and
       so the scalar loop would have done the VF stores too.

    4. Instead of searching for where to move stores to, they should always be
in
       exit belonging to the latch.  We can only ever delay stores and even if
we
       pick a different exit than the latch one as the main one, effects still
       happen in program order when vectorized.  If we don't move the stores to
the
       latch exit but instead to whever we pick as the "main" exit then we can
       perform incorrect memory accesses (luckily these are trapped by
verify_ssa).

    5. We only used to analyze loads inside the same BB as an early break, and
also
       we'd never analyze the ones inside the block where we'd be moving memory
       references to.  This is obviously bogus and to fix it this patch splits
apart
       the two constraints.  We first validate that all load memory references
are
       in bounds and only after that do we perform the alias checks for the
writes.
       This makes the code simpler to understand and more trivially correct.

    gcc/ChangeLog:

            PR tree-optimization/113137
            PR tree-optimization/113136
            PR tree-optimization/113172
            PR tree-optimization/113178
            * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
            Maintain PHIs on inverted loops.
            (vect_do_peeling): Maintain virtual PHIs on inverted loops.
            * tree-vect-loop.cc (vec_init_loop_exit_info): Pick exit closes to
            latch.
            (vect_create_loop_vinfo): Record all conds instead of only alt
ones.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/113137
            PR tree-optimization/113136
            PR tree-optimization/113172
            PR tree-optimization/113178
            * g++.dg/vect/vect-early-break_4-pr113137.cc: New test.
            * g++.dg/vect/vect-early-break_5-pr113137.cc: New test.
            * gcc.dg/vect/vect-early-break_95-pr113137.c: New test.
            * gcc.dg/vect/vect-early-break_96-pr113136.c: New test.
            * gcc.dg/vect/vect-early-break_97-pr113172.c: New test.

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

* [Bug middle-end/113172] [14 Regression] ice in move_early_exit_stmts
  2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2024-01-12 15:32 ` cvs-commit at gcc dot gnu.org
@ 2024-01-12 15:35 ` tnfchris at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2024-01-12 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Fixed. Thanks for the report and let me know if there's something still broken.

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

end of thread, other threads:[~2024-01-12 15:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29 19:14 [Bug c/113172] New: ice in move_early_exit_stmts dcb314 at hotmail dot com
2023-12-29 19:15 ` [Bug middle-end/113172] [14 Regression] " pinskia at gcc dot gnu.org
2023-12-29 20:34 ` tnfchris at gcc dot gnu.org
2023-12-29 21:06 ` tnfchris at gcc dot gnu.org
2024-01-10 13:27 ` rguenth at gcc dot gnu.org
2024-01-12 15:32 ` cvs-commit at gcc dot gnu.org
2024-01-12 15:35 ` tnfchris 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).