public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111833] New: GCC: 14: hangs on a simple for loop
@ 2023-10-16 12:28 141242068 at smail dot nju.edu.cn
  2023-10-16 12:29 ` [Bug c/111833] " 141242068 at smail dot nju.edu.cn
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2023-10-16 12:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111833
           Summary: GCC: 14: hangs on a simple for loop
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: [https://gcc.godbolt.org/](https://gcc.godbolt.org/)

Here is the code snippet that is causing the issue:

```c
unsigned char a[1];
unsigned char b;

void f(void) {
  unsigned char r = 0;
  int n;
  for (n = 8; n / sizeof(a); ++n) {
    b += b;
    r += b;
  }
}
```

This bug shares the same options as bug #111820, but the root cause seems to be
different:

While bug #111820 appears to get stuck in a loop when the initial value is zero
(as suggested by the comment `Maybe the loop should terminate when begin is
zero.`), this particular bug causes a hang starting from the initial value of
8. This suggests that the issue may not be tied to the initial loop value, but
some other aspect of the loop's iteration or the operations within it.

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

* [Bug c/111833] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
@ 2023-10-16 12:29 ` 141242068 at smail dot nju.edu.cn
  2023-10-16 16:47 ` [Bug tree-optimization/111833] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2023-10-16 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
The compiler explore link above is broken, here is the link:
https://gcc.godbolt.org/z/779zzjcze

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

* [Bug tree-optimization/111833] [14 Regression] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
  2023-10-16 12:29 ` [Bug c/111833] " 141242068 at smail dot nju.edu.cn
@ 2023-10-16 16:47 ` pinskia at gcc dot gnu.org
  2023-10-17  6:31 ` [Bug tree-optimization/111833] [13/14 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16 16:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

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

* [Bug tree-optimization/111833] [13/14 Regression] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
  2023-10-16 12:29 ` [Bug c/111833] " 141242068 at smail dot nju.edu.cn
  2023-10-16 16:47 ` [Bug tree-optimization/111833] [14 Regression] " pinskia at gcc dot gnu.org
@ 2023-10-17  6:31 ` rguenth at gcc dot gnu.org
  2023-10-23  1:16 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-17  6:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-10-17
     Ever confirmed|0                           |1
           Priority|P3                          |P2
            Summary|[14 Regression] GCC: 14:    |[13/14 Regression] GCC: 14:
                   |hangs on a simple for loop  |hangs on a simple for loop
      Known to fail|                            |13.2.1, 14.0
      Known to work|                            |12.3.1
   Target Milestone|14.0                        |13.3
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Really looks like a dup.  Confirmed (with -O3 -fno-tree-vrp).

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

* [Bug tree-optimization/111833] [13/14 Regression] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
                   ` (2 preceding siblings ...)
  2023-10-17  6:31 ` [Bug tree-optimization/111833] [13/14 " rguenth at gcc dot gnu.org
@ 2023-10-23  1:16 ` cvs-commit at gcc dot gnu.org
  2023-10-27  1:06 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-23  1:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

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

commit r14-4834-gdbde384bd56f07bfbcae86f81fc74aa92e3786ad
Author: liuhongt <hongtao.liu@intel.com>
Date:   Wed Oct 18 10:08:24 2023 +0800

    Avoid compile time hog on vect_peel_nonlinear_iv_init for nonlinear
induction vec_step_op_mul when iteration count is too big.

    There's loop in vect_peel_nonlinear_iv_init to get init_expr *
    pow (step_expr, skip_niters). When skipn_iters is too big, compile time
    hogs. To avoid that, optimize init_expr * pow (step_expr, skip_niters) to
    init_expr << (exact_log2 (step_expr) * skip_niters) when step_expr is
    pow of 2, otherwise give up vectorization when skip_niters >=
    TYPE_PRECISION (TREE_TYPE (init_expr)).

    Also give up vectorization when niters_skip is negative which will be
    used for fully masked loop.

    gcc/ChangeLog:

            PR tree-optimization/111820
            PR tree-optimization/111833
            * tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p): Give
            up vectorization for nonlinear iv vect_step_op_mul when
            step_expr is not exact_log2 and niters is greater than
            TYPE_PRECISION (TREE_TYPE (step_expr)). Also don't vectorize
            for nagative niters_skip which will be used by fully masked
            loop.
            (vect_can_advance_ivs_p): Pass whole phi_info to
            vect_can_peel_nonlinear_iv_p.
            * tree-vect-loop.cc (vect_peel_nonlinear_iv_init): Optimize
            init_expr * pow (step_expr, skipn) to init_expr
            << (log2 (step_expr) * skipn) when step_expr is exact_log2.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr111820-1.c: New test.
            * gcc.target/i386/pr111820-2.c: New test.
            * gcc.target/i386/pr111820-3.c: New test.
            * gcc.target/i386/pr103144-mul-1.c: Adjust testcase.
            * gcc.target/i386/pr103144-mul-2.c: Adjust testcase.

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

* [Bug tree-optimization/111833] [13/14 Regression] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
                   ` (3 preceding siblings ...)
  2023-10-23  1:16 ` cvs-commit at gcc dot gnu.org
@ 2023-10-27  1:06 ` cvs-commit at gcc dot gnu.org
  2023-10-27  3:08 ` crazylht at gmail dot com
  2023-10-27  3:29 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-27  1:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by hongtao Liu
<liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:82919cf4cb232166fed03d84a91fefd07feef6bb

commit r13-7988-g82919cf4cb232166fed03d84a91fefd07feef6bb
Author: liuhongt <hongtao.liu@intel.com>
Date:   Wed Oct 18 10:08:24 2023 +0800

    Avoid compile time hog on vect_peel_nonlinear_iv_init for nonlinear
induction vec_step_op_mul when iteration count is too big.

    There's loop in vect_peel_nonlinear_iv_init to get init_expr *
    pow (step_expr, skip_niters). When skipn_iters is too big, compile time
    hogs. To avoid that, optimize init_expr * pow (step_expr, skip_niters) to
    init_expr << (exact_log2 (step_expr) * skip_niters) when step_expr is
    pow of 2, otherwise give up vectorization when skip_niters >=
    TYPE_PRECISION (TREE_TYPE (init_expr)).

    Also give up vectorization when niters_skip is negative which will be
    used for fully masked loop.

    gcc/ChangeLog:

            PR tree-optimization/111820
            PR tree-optimization/111833
            * tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p): Give
            up vectorization for nonlinear iv vect_step_op_mul when
            step_expr is not exact_log2 and niters is greater than
            TYPE_PRECISION (TREE_TYPE (step_expr)). Also don't vectorize
            for nagative niters_skip which will be used by fully masked
            loop.
            (vect_can_advance_ivs_p): Pass whole phi_info to
            vect_can_peel_nonlinear_iv_p.
            * tree-vect-loop.cc (vect_peel_nonlinear_iv_init): Optimize
            init_expr * pow (step_expr, skipn) to init_expr
            << (log2 (step_expr) * skipn) when step_expr is exact_log2.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr111820-1.c: New test.
            * gcc.target/i386/pr111820-2.c: New test.
            * gcc.target/i386/pr111820-3.c: New test.
            * gcc.target/i386/pr103144-mul-1.c: Adjust testcase.
            * gcc.target/i386/pr103144-mul-2.c: Adjust testcase.

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

* [Bug tree-optimization/111833] [13/14 Regression] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
                   ` (4 preceding siblings ...)
  2023-10-27  1:06 ` cvs-commit at gcc dot gnu.org
@ 2023-10-27  3:08 ` crazylht at gmail dot com
  2023-10-27  3:29 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2023-10-27  3:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Hongtao.liu <crazylht at gmail dot com> ---
It's the same issue as PR111820, thus should be fixed.

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

* [Bug tree-optimization/111833] [13/14 Regression] GCC: 14: hangs on a simple for loop
  2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
                   ` (5 preceding siblings ...)
  2023-10-27  3:08 ` crazylht at gmail dot com
@ 2023-10-27  3:29 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  3:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

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

*** This bug has been marked as a duplicate of bug 111820 ***

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

end of thread, other threads:[~2023-10-27  3:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-16 12:28 [Bug c/111833] New: GCC: 14: hangs on a simple for loop 141242068 at smail dot nju.edu.cn
2023-10-16 12:29 ` [Bug c/111833] " 141242068 at smail dot nju.edu.cn
2023-10-16 16:47 ` [Bug tree-optimization/111833] [14 Regression] " pinskia at gcc dot gnu.org
2023-10-17  6:31 ` [Bug tree-optimization/111833] [13/14 " rguenth at gcc dot gnu.org
2023-10-23  1:16 ` cvs-commit at gcc dot gnu.org
2023-10-27  1:06 ` cvs-commit at gcc dot gnu.org
2023-10-27  3:08 ` crazylht at gmail dot com
2023-10-27  3:29 ` 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).