Bug 105437 - [11 Regression] ICE on GIMPLE pass slp when vectorizer is enabled since r11-1801-g9e5508c2d006f2d4
Summary: [11 Regression] ICE on GIMPLE pass slp when vectorizer is enabled since r11-1...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.2.1
: P2 normal
Target Milestone: 11.4
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2022-04-29 21:19 UTC by Giuliano Belinassi
Modified: 2024-03-11 22:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 11.3.1, 12.1.1, 13.0
Known to fail: 11.3.0, 12.1.0
Last reconfirmed: 2022-05-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giuliano Belinassi 2022-04-29 21:19:37 UTC
Given the following C++ input:
```
struct ControlClass
{
    virtual ~ControlClass();

    int Width;
    int Height;
    unsigned IsToRepaint : 1;
};

struct SelectClass : ControlClass
{
    SelectClass(void);
};

int Non_Folded_Value();

SelectClass::SelectClass(void)
{
    int factor = Non_Folded_Value();
    Width = 32 << factor;
    Height = 24 << factor;
}
```

saved as bug.cpp, and compiling with:

> g++-11 -O2 -ftree-vectorize -S bug.cpp

results in the following ICE:
```
during GIMPLE pass: ehcleanup
bug.cpp: In constructor ‘SelectClass::SelectClass()’:
bug.cpp:17:1: internal compiler error: in mark_reachable_handlers, at tree->eh.c:4036
   17 | SelectClass::SelectClass(void)
      | ^~~~~~~~~~~
0x7f03bd2cd2bc __libc_start_main
        ???:0
```

This bug is still present on trunk. It happens even without -ftree-vectorize, but the output is:
```
bug.cpp: In constructor ‘SelectClass::SelectClass()’:
bug.cpp:17:1: error: statement marked for throw in middle of block
   17 | SelectClass::SelectClass(void)
      | ^~~~~~~~~~~
# .MEM_8 = VDEF <.MEM_7>
_9 = Non_Folded_Value ();
during GIMPLE pass: slp
bug.cpp:17:1: internal compiler error: verify_gimple failed
0x112f364 verify_gimple_in_cfg(function*, bool)
        ../../gcc/gcc/tree-cfg.cc:5561
0xfd5eae execute_function_todo
        ../../gcc/gcc/passes.cc:2085
0xfd6932 execute_todo
        ../../gcc/gcc/passes.cc:2139

```

I tracked this issue back to commit 9e5508c2d006f2d4f8670e6c3fed770ac1c85e64:
"refactor SLP constant insertion and provde entry insert helper", but simple `git revert` doesn't work as one of the files seems to have been deleted/moved.

GCC-10 and older are unaffected. (tested until gcc 7.5.0)
Comment 1 Richard Biener 2022-05-02 06:47:23 UTC
I will have a look.
Comment 2 GCC Commits 2022-05-02 08:43:57 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:3a3eda000fdf4f8754c9a2535191091f1db0c2a2

commit r13-66-g3a3eda000fdf4f8754c9a2535191091f1db0c2a2
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 2 09:30:27 2022 +0200

    tree-optimization/105437 - BB vect with extern defs of throwing stmts
    
    We have to watch out for vectorized stmt insert locations if the
    def from the last stmt alters control flow.  We constrain region
    building so we know the def is outside of the current region
    and thus we can insert at the region start point.
    
    2022-05-02  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/105437
            * tree-vect-slp.cc (vect_schedule_slp_node): Handle the
            case where last_stmt alters control flow.
    
            * g++.dg/vect/pr105437.cc: New testcase.
Comment 3 Richard Biener 2022-05-02 08:44:45 UTC
Fixed on trunk sofar.
Comment 4 GCC Commits 2022-05-06 09:27:59 UTC
The releases/gcc-12 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:30b5b785abfff334bb50d7fd2051e991324f051f

commit r12-8342-g30b5b785abfff334bb50d7fd2051e991324f051f
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 2 09:30:27 2022 +0200

    tree-optimization/105437 - BB vect with extern defs of throwing stmts
    
    We have to watch out for vectorized stmt insert locations if the
    def from the last stmt alters control flow.  We constrain region
    building so we know the def is outside of the current region
    and thus we can insert at the region start point.
    
    2022-05-02  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/105437
            * tree-vect-slp.cc (vect_schedule_slp_node): Handle the
            case where last_stmt alters control flow.
    
            * g++.dg/vect/pr105437.cc: New testcase.
    
    (cherry picked from commit 3a3eda000fdf4f8754c9a2535191091f1db0c2a2)
Comment 5 GCC Commits 2022-06-02 10:56:50 UTC
The releases/gcc-11 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:462e7e2c6fe0bc57e03110d43a2c7e53a1ce04ea

commit r11-10045-g462e7e2c6fe0bc57e03110d43a2c7e53a1ce04ea
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 2 09:30:27 2022 +0200

    tree-optimization/105437 - BB vect with extern defs of throwing stmts
    
    We have to watch out for vectorized stmt insert locations if the
    def from the last stmt alters control flow.  We constrain region
    building so we know the def is outside of the current region
    and thus we can insert at the region start point.
    
    2022-05-02  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/105437
            * tree-vect-slp.c (vect_schedule_slp_node): Handle the
            case where last_stmt alters control flow.
    
            * g++.dg/vect/pr105437.cc: New testcase.
    
    (cherry picked from commit 3a3eda000fdf4f8754c9a2535191091f1db0c2a2)
Comment 6 Richard Biener 2022-06-02 10:57:08 UTC
Fixed.
Comment 7 GCC Commits 2024-03-11 22:24:52 UTC
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:0c179654c3170749f3fb3232f2442fcbc99bffbb

commit r14-9432-g0c179654c3170749f3fb3232f2442fcbc99bffbb
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Mon Mar 11 15:15:34 2024 -0700

    libgfortran: [PR114304] Revert portion of PR105347 change.
    
            PR libfortran/105437
            PR libfortran/114304
    
    libgfortran/ChangeLog:
    
            * io/list_read.c (eat_separator): Remove check for decimal
            point mode and semicolon used as a seprator. Removes
            the regression.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/pr105473.f90: Add additional checks to address
            the case of semicolon at the end of a line.
Comment 8 GCC Commits 2024-03-11 22:45:59 UTC
The releases/gcc-13 branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:824a71f609b37a8121793075b175e2bbe14fdb82

commit r13-8417-g824a71f609b37a8121793075b175e2bbe14fdb82
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Mon Mar 11 15:15:34 2024 -0700

    libgfortran: [PR114304] Revert portion of PR105347 change.
    
            PR libfortran/105437
            PR libfortran/114304
    
    libgfortran/ChangeLog:
    
            * io/list_read.c (eat_separator): Remove check for decimal
            point mode and semicolon used as a seprator. Removes
            the regression.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/pr105473.f90: Add additional checks to address
            the case of semicolon at the end of a line.
    
    (cherry picked from commit 0c179654c3170749f3fb3232f2442fcbc99bffbb)