Bug 95717 - [9 Regression] ICE during GIMPLE pass: vect: verify_ssa failed since r9-5325-gf25507d041de4df6
Summary: [9 Regression] ICE during GIMPLE pass: vect: verify_ssa failed since r9-5325-...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P2 normal
Target Milestone: 9.4
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2020-06-17 06:59 UTC by Vsevolod Livinskii
Modified: 2021-11-01 23:07 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.1.1, 11.0, 9.3.1
Known to fail: 10.1.0, 9.3.0
Last reconfirmed: 2020-06-17 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-06-17 06:59:58 UTC
Error:
$ g++ -c -O3 func.cpp
func.cpp: In function ‘void g(bool)’:
func.cpp:5:6: error: definition in block 61 does not dominate use in block 59
    5 | void g(bool h) {
      |      ^
for SSA_NAME: prephitmp_100 in statement:
prephitmp_100 = PHI <prephitmp_100(59), _103(62)>
PHI argument
prephitmp_100
for PHI node
prephitmp_100 = PHI <prephitmp_100(59), _103(62)>
during GIMPLE pass: vect
func.cpp:5:6: internal compiler error: verify_ssa failed
0x13368a2 verify_ssa(bool, bool)
        gcc/tree-ssa.c:1208
0x10228a5 execute_function_todo
        gcc/passes.c:1992
0x102357e execute_todo
        gcc/passes.c:2039

Reproducer:
bool a;
extern bool b[];
long c, d;
int *f;
void g(bool h) {
  for (short e = 0; e < c; e = 4)
    for (; d; d++)
      b[d] = a = f[d] ? c ? h : 0 : h;
}

GCC version:
gcc version 11.0.0 (56638b9b1853666f575928f8baf17f70e4ed3517)
Comment 1 Vsevolod Livinskii 2020-06-17 07:00:44 UTC
It might be related to bug 94443
Comment 2 Martin Liška 2020-06-17 07:10:14 UTC
Started with r9-5325-gf25507d041de4df6.
Comment 3 Richard Biener 2020-06-17 09:06:00 UTC
I'll have a look.  There's a missed optimization but that causes the SSA update
mechanism in the vectorizer to go out-of-sync somehow.
Comment 4 Richard Biener 2020-06-17 11:46:57 UTC
The bogus def is set via

  if (scalar_loop != loop)
    {
      /* If we copied from SCALAR_LOOP rather than LOOP, SSA_NAMEs from
         SCALAR_LOOP will have current_def set to SSA_NAMEs in the new_loop,
         but LOOP will not.  slpeel_update_phi_nodes_for_guard{1,2} expects
         the LOOP SSA_NAMEs (on the exit edge and edge from latch to
         header) to have current_def set, so copy them over.  */ 
      slpeel_duplicate_current_defs_from_edges (single_exit (scalar_loop),
                                                exit);

because that interferes with the renaming process.  The if-conversion
applied the missed optimization to the to-be vectorized loop introducing
a LC PHI (required for the not if-converted copy) which has one invariant
and one non-invariant arg.

So we have to do that copying after renaming in the BBs.  That seems to work,
testing patch.
Comment 5 GCC Commits 2020-06-17 13:03:15 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

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

commit r11-1447-gd0909f5858ad81e6d8b73fa6193be19cb5e6ed7b
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jun 17 14:57:59 2020 +0200

    tree-optimization/95717 - fix SSA update for vectorizer epilogue
    
    This fixes yet another issue with the custom SSA updating in the
    vectorizer when we copy from the non-if-converted loop.  We must
    not mess with current defs before we updated the BB copies.
    
    2020-06-17  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95717
            * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
            Move BB SSA updating before exit/latch PHI current def copying.
    
            * g++.dg/torture/pr95717.C: New testcase.
Comment 6 Richard Biener 2020-06-17 13:03:51 UTC
Fixed on trunk sofar.
Comment 7 GCC Commits 2020-06-24 07:02:20 UTC
The releases/gcc-10 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

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

commit r10-8359-gf3a27a610b0eb9a7ea76f61b4fecf7e66e86a3e1
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jun 17 14:57:59 2020 +0200

    tree-optimization/95717 - fix SSA update for vectorizer epilogue
    
    This fixes yet another issue with the custom SSA updating in the
    vectorizer when we copy from the non-if-converted loop.  We must
    not mess with current defs before we updated the BB copies.
    
    2020-06-17  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95717
            * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
            Move BB SSA updating before exit/latch PHI current def copying.
    
            * g++.dg/torture/pr95717.C: New testcase.
    
    (cherry picked from commit d0909f5858ad81e6d8b73fa6193be19cb5e6ed7b)
Comment 8 GCC Commits 2020-09-11 10:37:53 UTC
The releases/gcc-9 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1102a2c1fd221ee38f2f41aaf1094d4abbc3aedc

commit r9-8861-g1102a2c1fd221ee38f2f41aaf1094d4abbc3aedc
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jun 17 14:57:59 2020 +0200

    tree-optimization/95717 - fix SSA update for vectorizer epilogue
    
    This fixes yet another issue with the custom SSA updating in the
    vectorizer when we copy from the non-if-converted loop.  We must
    not mess with current defs before we updated the BB copies.
    
    2020-06-17  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95717
            * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
            Move BB SSA updating before exit/latch PHI current def copying.
    
            * g++.dg/torture/pr95717.C: New testcase.
    
    (cherry picked from commit d0909f5858ad81e6d8b73fa6193be19cb5e6ed7b)
Comment 9 Richard Biener 2020-09-11 10:38:48 UTC
Fixed.