Bug 98064 - ICE in check_loop_closed_ssa_def, at tree-ssa-loop-manip.c:726 with -O3 since r11-4921-g86cca5cc14602814
Summary: ICE in check_loop_closed_ssa_def, at tree-ssa-loop-manip.c:726 with -O3 since...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2020-11-30 06:43 UTC by Vsevolod Livinskii
Modified: 2021-11-01 23:07 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-11-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2020-11-30 06:43:35 UTC
Error:
>$ g++ -c -O3 func.cpp
during GIMPLE pass: slp
func.cpp: In function ‘void test()’:
func.cpp:8:6: internal compiler error: in check_loop_closed_ssa_def, at tree-ssa-loop-manip.c:726
    8 | void test() {
      |      ^~~~
0x84b706 check_loop_closed_ssa_def
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:726
0x12ae78d check_loop_closed_ssa_bb
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:752
0x12b05d6 verify_loop_closed_ssa(bool, loop*)
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:777
0x12b05d6 verify_loop_closed_ssa(bool, loop*)
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:761
0x1062c24 execute_function_todo
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/passes.c:2057
0x10638ae execute_todo
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/passes.c:2093
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.

Reproducer:
#include <algorithm>
extern long var_2;
extern int var_3, var_8;
extern long long var_5;
extern unsigned short arr_353[];
extern short arr_362[];
extern int arr_518[];
void test() {
    for (char d = 0; d < 013; d += 4) {
        for (char e = 0; e < 11; e++)
            arr_353[e] = var_2 | std::min((long long)7, var_5);
        for (int f = var_5; f; f += 4)
            for (short g = var_8; g; g++)
                arr_362[g] = 0;
    }
    for (short h = 5; (short)var_2; h += 5)
        arr_518[h] = 0;
}


gcc version 11.0.0 20201126 (beb9afcaf1466996a301c778596c5df209e7913c)
Comment 1 Richard Biener 2020-11-30 08:15:26 UTC
I will have a look.
Comment 2 Martin Liška 2020-11-30 09:12:45 UTC
For the record, started with r11-4921-g86cca5cc14602814.
Comment 3 Richard Biener 2020-11-30 11:58:26 UTC
The issue is

t.C:11:24: note: extracting lane for live stmt _201 = (signed short) pretmp_25;

where the vectorized def of this out-of-loop definition is in-loop and thus
replacing its uses would require a LC-SSA def.
Comment 4 GCC Commits 2020-11-30 13:30:07 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

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

commit r11-5542-gebbe3f29518854c36574adbd4fa82fd56fa64056
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 30 13:39:59 2020 +0100

    tree-optimization/98064 - fix BB SLP live lane extract wrt LC SSA
    
    This avoids breaking LC SSA when SLP codegen pulled an out-of-loop
    def into a loop when merging with in-loop defs for an external def.
    
    2020-11-30  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/98064
            * tree-vect-loop.c (vectorizable_live_operation): Avoid
            breaking LC SSA for BB vectorization.
    
            * g++.dg/vect/pr98064.cc: New testcase.
Comment 5 Richard Biener 2020-11-30 13:30:29 UTC
Fixed.