Bug 97709 - powerpc: ICE when building glibc with latest gcc
Summary: powerpc: ICE when building glibc with latest gcc
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:
Depends on:
Blocks:
 
Reported: 2020-11-03 20:42 UTC by Matheus Castanho
Modified: 2020-11-04 14:04 UTC (History)
2 users (show)

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


Attachments
Pre-processed source with the issue (80.54 KB, text/plain)
2020-11-03 20:42 UTC, Matheus Castanho
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matheus Castanho 2020-11-03 20:42:33 UTC
Created attachment 49499 [details]
Pre-processed source with the issue

This was first observed when upgrading GCC on Advance Toolchain, but I was also able to reproduce this with upstream GCC (commit 93e79ed391b9c636f0). 

Trying to build glibc with latest GCC causes an internal compiler error:

vfprintf-internal.c: In function ‘__vfprintf_internal’:
vfprintf-internal.c:1320:1: error: SSA_NAME_OCCURS_IN_ABNORMAL_PHI should be set
for SSA_NAME: _1972 in statement:
prec_413(ab) = PHI <_1972(36)>
PHI argument
_1972
for PHI node
prec_413(ab) = PHI <_1972(36)>
during GIMPLE pass: slp
vfprintf-internal.c:1320:1: internal compiler error: verify_ssa failed
0x10dfa0d3 verify_ssa(bool, bool)
        /home/mscastanho/src/gcc/gcc/tree-ssa.c:1208
0x1099fc1f execute_function_todo
        /home/mscastanho/src/gcc/gcc/passes.c:2046
0x109a088b do_per_function
        /home/mscastanho/src/gcc/gcc/passes.c:1687
0x109a0aaf execute_todo
        /home/mscastanho/src/gcc/gcc/passes.c:2093
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.



Preprocessed source generated with -save-temps is attached to the bug. The issue only happens if I use -mcpu=power9 or -mcpu=power10. -mcpu=power8 seems to be OK.

Cmdline used:
~/usr/bin/gcc -m64 ./stdio-common/vfprintf-internal.i -c -std=gnu11 -fgnu89-inline  -g -O3 -mcpu=power9 -Wall



NOTE: The original Advance Toolchain build used a slightly older GCC (commit 943cc2a1b70f), and the error message I saw was a bit different (although still somewhat related):

Unable to coalesce ssa_names 219 and 1972 which are marked as MUST COALESCE.                                                                                                                                                                                 prec_219(ab) and  _1972                         
during RTL pass: expand
vfprintf-internal.c: In function ‘__vfprintf_internal’:
vfprintf-internal.c:148:25: internal compiler error: SSA corruption               
  148 | # define vfprintf       __vfprintf_internal                                                                           
      |                         ^~~~~~~~~~~~~~~~~~~                                                                           
vfprintf-internal.c:1320:1: note: in expansion of macro ‘vfprintf’                                                            
 1320 | vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags)
      | ^~~~~~~~                                                                                                              
0x109e7dc7 fail_abnormal_edge_coalesce                         
        /home/mscastanho/AT/broken-gcc-p910/build/at15.0-0-alpha.redhat-8_ppc64le_ppc64le/sources/gcc/gcc/tree-ssa-coalesce.c:1003                                                                                                                           
0x109e7dc7 coalesce_partitions   
        /home/mscastanho/AT/broken-gcc-p910/build/at15.0-0-alpha.redhat-8_ppc64le_ppc64le/sources/gcc/gcc/tree-ssa-coalesce.c:1425
0x109e7dc7 coalesce_ssa_name(_var_map*)
        /home/mscastanho/AT/broken-gcc-p910/build/at15.0-0-alpha.redhat-8_ppc64le_ppc64le/sources/gcc/gcc/tree-ssa-coalesce.c:1755
0x1097f8bb remove_ssa_form
        /home/mscastanho/AT/broken-gcc-p910/build/at15.0-0-alpha.redhat-8_ppc64le_ppc64le/sources/gcc/gcc/tree-outof-ssa.c:1065
0x1097f8bb rewrite_out_of_ssa(ssaexpand*)
        /home/mscastanho/AT/broken-gcc-p910/build/at15.0-0-alpha.redhat-8_ppc64le_ppc64le/sources/gcc/gcc/tree-outof-ssa.c:1323
0x1035f04b execute
        /home/mscastanho/AT/broken-gcc-p910/build/at15.0-0-alpha.redhat-8_ppc64le_ppc64le/sources/gcc/gcc/cfgexpand.c:6378
Comment 1 Richard Biener 2020-11-04 08:31:33 UTC
I will try to have a look.
Comment 2 Richard Biener 2020-11-04 08:54:45 UTC
The testcase suggests powerpc64le where I can reproduce the issue.  Reducing.
Comment 3 Richard Biener 2020-11-04 10:03:17 UTC
Reduced testcase:

int a;
struct b {
  int c;
  int d;
}; 
void k (struct b);
struct b 
e() 
{
  void *f[] = {&&g, &&h, &&i, &&j};
  int d, c;
j:
  goto *a;
g:
  d = 0;
h:
  c = 1;
  goto *a;
i: 
  {
    struct b b = {c, d};
    k(b);
  }
}
Comment 4 GCC Commits 2020-11-04 11:41:24 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1e9f339d946b8296e3785bec77e03d71b487d689

commit r11-4718-g1e9f339d946b8296e3785bec77e03d71b487d689
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Nov 4 11:20:17 2020 +0100

    tree-optimization/97709 - set abnormal flag when vectorizing live lanes
    
    This properly sets the abnormal flag when vectorizing live lanes
    when the original scalar was live across an abnormal edge.
    
    2020-11-04  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/97709
            * tree-vect-loop.c (vectorizable_live_operation): Set
            SSA_NAME_OCCURS_IN_ABNORMAL_PHI when necessary.
    
            * gcc.dg/vect/bb-slp-pr97709.c: New testcase.
Comment 5 Richard Biener 2020-11-04 14:04:56 UTC
Fixed.