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

            Bug ID: 119804
           Summary: [14/15 regression] compiler hang at -O1
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chopra.kavya04 at gmail dot com
  Target Milestone: ---

gcc14 and trunk hang at -O1 with this code snippet. Godbolt link:
https://godbolt.org/z/WGhGWbq8b

kchopra@ast-epyc5:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/local/home/kchopra/compilers/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/local/home/kchopra/compilers/
--with-local-prefix=/local/home/kchopra/compilers/
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.1 20250408 (experimental) (GCC) 
kchopra@ast-epyc5:~$ timeout -s 9 3 gcc -O0 bug.c ; ./a.out 
kchopra@ast-epyc5:~$ timeout -s 9 3 gcc -O1 bug.c ; ./a.out 
Killed
kchopra@ast-epyc5:~$ cat bug.c 
int a ;
int b ;
int c ;
int d ;
int e ;
int f = -1;
int main() {                      
    a = -f ;                          
    goto g;                      
    h:     
        a = 2   * d -1;                          
        if (b ) goto i;                          
        if (a >= 0) goto h;                      
    j:     b =  5 * a ;                          
    if (503061704 * b -1918663653 >= 0) goto k;                      
    i:      
    l:                         
        c = d + 407529;                          
        if (c   ) goto j;                           
    g:     
        e = -a ;                          
        if (e >= 0) goto h;                          
        goto m;                      
    k:     
        if (d ) goto l;                      
    m:     
        return 0;
}

Reply via email to