Bug 109392 - [12 Regression] ICE in tree_vec_extract, at tree-vect-generic.cc:177 since r12-117-gb972e036f40c
Summary: [12 Regression] ICE in tree_vec_extract, at tree-vect-generic.cc:177 since r1...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 13.0
: P2 normal
Target Milestone: 12.3
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2023-04-03 16:50 UTC by G. Steinmetz
Modified: 2023-04-27 13:20 UTC (History)
4 users (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 12.2.0
Last reconfirmed: 2023-04-04 00:00:00


Attachments
gcc13-pr109392.patch (826 bytes, patch)
2023-04-04 12:46 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2023-04-03 16:50:23 UTC
Started with r12 before 20210502 :


$ cat z1.c
typedef short __attribute__ ((__vector_size__ (64))) V;
V v, w;
inline V foo (V a, V b);
V
foo (V a, V b)
{
  vfork();
  b &= v < b;
  return (V){foo (b, w)[3], (V){}[3]};
}


$ gcc-13-20230402 -c z1.c
z1.c: In function 'foo':
z1.c:6:1: warning: AVX512F vector return without AVX512F enabled changes the ABI [-Wpsabi]
    6 | {
      | ^
z1.c:7:3: warning: implicit declaration of function 'vfork' [-Wimplicit-function-declaration]
    7 |   vfork();
      |   ^~~~~
z1.c:5:1: note: the ABI for passing parameters with 64-byte alignment has changed in GCC 4.6
    5 | foo (V a, V b)
      | ^~~
during GIMPLE pass: veclower
z1.c:5:1: internal compiler error: in tree_vec_extract, at tree-vect-generic.cc:177
0x111bdd6 tree_vec_extract(gimple_stmt_iterator*, tree_node*, tree_node*, tree_node*, tree_node*)
        ../../gcc/tree-vect-generic.cc:177
0x111f8fb expand_vector_condition
        ../../gcc/tree-vect-generic.cc:1140
0x6cac8d expand_vector_comparison
        ../../gcc/tree-vect-generic.cc:453
0x11229c1 expand_vector_operation
        ../../gcc/tree-vect-generic.cc:1239
0x11229c1 expand_vector_operations_1
        ../../gcc/tree-vect-generic.cc:2357
0x11229c1 expand_vector_operations
        ../../gcc/tree-vect-generic.cc:2391
0x11229c1 execute
        ../../gcc/tree-vect-generic.cc:2445
Comment 1 Andrew Pinski 2023-04-04 00:45:40 UTC
Confirmed.

Most likely caused by r12-117-gb972e036f40c .

I think the assert happens because the argument t is abnormal SSA_NAME and resimplify/maybe_push_res_to_seq decides it can't do anything on it so returns null.
Comment 2 Andrew Pinski 2023-04-04 00:47:20 UTC
here is a better testcase which does not use vfork which is implicit returns_twice:
```
typedef short __attribute__ ((__vector_size__ (64))) V;
V v, w;
void g(void) __attribute__((returns_twice));
V foo (V a, V b)
{
  g();
  b &= v < b;
  return (V){foo (b, w)[3], (V){}[3]};
}
```
Comment 3 Martin Liška 2023-04-04 08:14:29 UTC
(In reply to Andrew Pinski from comment #1)
> Confirmed.
> 
> Most likely caused by r12-117-gb972e036f40c .

Yes, started with this revision.
Comment 4 Jakub Jelinek 2023-04-04 12:46:03 UTC
Created attachment 54807 [details]
gcc13-pr109392.patch

Untested fix.
Comment 5 GCC Commits 2023-04-08 18:24:54 UTC
The master branch has been updated by Jeff Law <law@gcc.gnu.org>:

https://gcc.gnu.org/g:101380a8394c22a7a2ea70de2060ee93716156e2

commit r13-7126-g101380a8394c22a7a2ea70de2060ee93716156e2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Apr 8 12:21:42 2023 -0600

    PR tree-optimization/109392
    
    If we have an object with SSA_NAME_OCCURS_IN_ABNORMAL_PHI, then
    maybe_push_res_to_seq may fail.  Directly build the extraction
    for that case.
    
            PR tree-optimization/109392
    
    gcc/
            * tree-vect-generic.cc (tree_vec_extract): Handle failure
            of maybe_push_res_to_seq better.
    
    gcc/testsuite/
    
            * gcc.dg/pr109392.c: New test.
Comment 6 GCC Commits 2023-04-27 13:19:12 UTC
The releases/gcc-12 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

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

commit r12-9482-gd639236ea87ff8a6a2d56c0408e6eb92674418e6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Apr 8 12:21:42 2023 -0600

    PR tree-optimization/109392
    
    If we have an object with SSA_NAME_OCCURS_IN_ABNORMAL_PHI, then
    maybe_push_res_to_seq may fail.  Directly build the extraction
    for that case.
    
            PR tree-optimization/109392
    
    gcc/
            * tree-vect-generic.cc (tree_vec_extract): Handle failure
            of maybe_push_res_to_seq better.
    
    gcc/testsuite/
    
            * gcc.dg/pr109392.c: New test.
    
    (cherry picked from commit 101380a8394c22a7a2ea70de2060ee93716156e2)
Comment 7 Richard Biener 2023-04-27 13:20:29 UTC
Fixed.