Bug 100761 - [mips+msa] ICE when using __builtin_convertvector to convert from u8x8 to u8x16
Summary: [mips+msa] ICE when using __builtin_convertvector to convert from u8x8 to u8x16
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2021-05-26 03:52 UTC by Evan Nemerson
Modified: 2021-07-09 06:29 UTC (History)
1 user (show)

See Also:
Host:
Target: mips
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evan Nemerson 2021-05-26 03:52:15 UTC
I'm seeing an ICE from MIPS with MSA enabled when attempting to use __builtin_convertvector to convert a vector of 8 unsigned 8-bit integers to 8 unsigned 16-bit integers.

Here is a reduced test case, courtesy of C-Reduce:


typedef char a;
typedef short b;
typedef struct {
  a c __attribute__((__vector_size__(8)));
} d;
d e;
void f() {
  b g __attribute__((__vector_size__(16))) (
      __builtin_convertvector(e.c, __typeof__(g)));
}


$ mips64el-linux-gnuabi64-g++-10 -march=loongson3a -mmsa -c -o test.o test.c
during RTL pass: expand
test.c: In function 'void f()':
test.c:8:5: internal compiler error: in mips_expand_vec_unpack, at config/mips/mips.c:21757
    8 |   b g __attribute__((__vector_size__(16))) (
      |     ^
0x7fed0d1f9d09 __libc_start_main
	../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.


This is with GCC 10.2.1-6 from Debian:

$ mips64el-linux-gnuabi64-g++-10 --version                                  
mips64el-linux-gnuabi64-g++-10 (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Original code is at https://github.com/simd-everywhere/simde/blob/7d0e2aca9458f760d7196b94bfdcf83b2178ea24/simde/x86/sse.h#L1046, SIMDE_CONVERT_VECTOR_ is defined at https://github.com/simd-everywhere/simde/blob/7d0e2aca9458f760d7196b94bfdcf83b2178ea24/simde/simde-common.h#L292-L296
Comment 1 Xi Ruoyao 2021-06-19 07:36:40 UTC
Patch proposed: https://gcc.gnu.org/pipermail/gcc-patches/2021-June/573213.html
Comment 2 CVS Commits 2021-07-09 06:29:30 UTC
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:

https://gcc.gnu.org/g:82625a42e652d52fc6bbe6070f8d0589d5e0c8ad

commit r12-2183-g82625a42e652d52fc6bbe6070f8d0589d5e0c8ad
Author: Xi Ruoyao <xry111@mengyan1223.wang>
Date:   Fri Jun 18 20:11:42 2021 +0800

    mips: check MSA support for vector modes [PR100760,PR100761,PR100762]
    
    Check if the vector mode is really supported by MSA in certain cases,
    instead of testing ISA_HAS_MSA.  Simply testing ISA_HAS_MSA can cause
    ICE when MSA is enabled besides other MIPS SIMD extensions (notably,
    Loongson MMI).
    
    gcc/
    
            PR target/100760
            PR target/100761
            PR target/100762
            * config/mips/mips.c (mips_const_insns): Use MSA_SUPPORTED_MODE_P
            instead of ISA_HAS_MSA.
            (mips_expand_vec_unpack): Likewise.
            (mips_expand_vector_init): Likewise.
    
    gcc/testsuite/
    
            PR target/100760
            PR target/100761
            PR target/100762
            * gcc.target/mips/pr100760.c: New test.
            * gcc.target/mips/pr100761.c: New test.
            * gcc.target/mips/pr100762.c: New test.