Bug 98872 - ICE leads to SEGV on MMA test case
Summary: ICE leads to SEGV on MMA test case
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Peter Bergner
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-28 22:49 UTC by Peter Bergner
Modified: 2021-11-08 08:53 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-01-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Bergner 2021-01-28 22:49:48 UTC
bergner@pike:~/gcc/BUGS/MMA$ cat ice3.i 
typedef unsigned char vec_t __attribute__((vector_size(16)));
int
foo (vec_t *rowA, vec_t *rowB, vec_t *dst)
{
  __vector_quad acc0;
  __builtin_mma_xvf32gerpp (&acc0, rowB[0], rowA[0]);
  __builtin_mma_disassemble_acc (dst, &acc0);
}

bergner@pike:~/gcc/BUGS/MMA$ /home/bergner/gcc/build/gcc-fsf-mainline-mma-builtins-debug/gcc/xgcc -B/home/bergner/gcc/build/gcc-fsf-mainline-mma-builtins-debug/gcc -S -O2 -mcpu=power10 ice3.i 
during RTL pass: init-regs
ice3.i: In function ‘foo’:
ice3.i:8:1: internal compiler error: Segmentation fault
    8 | }
      | ^
0x113d6697 crash_signal
	/home/bergner/gcc/gcc-fsf-mainline-mma-builtins/gcc/toplev.c:327
0x10b436c4 emit_move_insn(rtx_def*, rtx_def*)
	/home/bergner/gcc/gcc-fsf-mainline-mma-builtins/gcc/expr.c:3821
0x1289319b initialize_uninitialized_regs
	/home/bergner/gcc/gcc-fsf-mainline-mma-builtins/gcc/init-regs.c:108
0x12893443 execute
	/home/bergner/gcc/gcc-fsf-mainline-mma-builtins/gcc/init-regs.c:156
Comment 1 Peter Bergner 2021-01-28 22:51:43 UTC
Raji reported the above ICE/SEGV.  This probably also affects GCC10.

Mine.
Comment 2 Peter Bergner 2021-02-04 00:05:17 UTC
The problem is caused by using an uninitialized __vector_quad (or __vector_pair) variable.  In those cases, initialize_uninitialized_regs() detects that and emits an initialization via:

  emit_move_insn (reg, CONST0_RTX (GET_MODE (reg)));

The problem is we don't have CONST0_RTX(mode) defined for opaque modes, so it returns NULL which leads to the ICE.  I have a patch I'm testing to add that support.
Comment 3 GCC Commits 2021-02-15 16:39:49 UTC
The master branch has been updated by Peter Bergner <bergner@gcc.gnu.org>:

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

commit r11-7249-ga33927c9ab4af3f4595251ce0c8ba54db821b039
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Mon Feb 15 10:38:33 2021 -0600

    rtl-optimization: Fix uninitialized use of opaque mode variable ICE [PR98872]
    
    The initialize_uninitialized_regs function emits (set (reg:) (CONST0_RTX))
    for all uninitialized pseudo uses.  However, some modes (eg, opaque modes)
    may not have a CONST0_RTX defined, leading to an ICE when we try and create
    the initialization insn.  The fix is to skip emitting the initialization
    if there is no CONST0_RTX defined for the mode.
    
    2021-02-15  Peter Bergner  <bergner@linux.ibm.com>
    
    gcc/
            PR rtl-optimization/98872
            * init-regs.c (initialize_uninitialized_regs): Skip initialization
            if CONST0_RTX is NULL.
    
    gcc/testsuite/
            PR rtl-optimization/98872
            * gcc.target/powerpc/pr98872.c: New test.
Comment 4 Peter Bergner 2021-02-15 17:38:25 UTC
Fixed.  No backport needed.