https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128780
Bug ID: 128780
Summary: ICE on AArch64 with an __int128 register variable in
x30
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mumumu0722 at gmail dot com
Target Milestone: ---
GCC aarch64 ICEs ("insn does not satisfy its constraints") when an `__int128`
local register variable is placed in x30 and used as an inline asm operand. The
value needs the pair x30:x31, and x31 is SP.
Similar bug: 128778
__int128 f(__int128 v)
{
register __int128 x __asm__("x30") = v;
__asm__ volatile("" : "+r"(x));
return x;
}
$ aarch64-linux-gnu-gcc -S test.c
test.c: In function 'f':
test.c:6:1: error: insn does not satisfy its constraints:
6 | }
| ^
(insn 19 6 20 2 (set (reg/v:TI 30 x30 [ x ])
(reg/v:TI 0 x0 [orig:105 x ] [105])) "test.c":3:23 124 {*movti_aarch64}
(nil))
during RTL pass: reload
test.c:6:1: internal compiler error: in extract_constrain_insn, at
recog.cc:2856
Output of `-freport-bug` (GCC trunk 4182b22649d4, `aarch64-linux-gnu-gcc
-freport-bug -S test.c`):
```
// Target: aarch64-linux-gnu
// Configured with: /src/gcc/configure --target=aarch64-linux-gnu
--prefix=/opt/cross --enable-languages=c --without-headers --disable-bootstrap
--disable-multilib --disable-nls --disable-werror
// Thread model: posix
// Supported LTO compression algorithms: zlib
// gcc version 17.0.0 20261115 (experimental) (GCC)
//
// test.c: In function 'f':
// test.c:6:1: error: insn does not satisfy its constraints:
// 6 | }
// | ^
// (insn 19 6 20 2 (set (reg/v:TI 30 x30 [ x ])
// (reg/v:TI 0 x0 [orig:105 x ] [105])) "test.c":3:23 124
{*movti_aarch64}
// (nil))
// during RTL pass: reload
// test.c:6:1: internal compiler error: in extract_constrain_insn, at
recog.cc:2856
// 0x27c3eed internal_error(char const*, ...)
// /src/gcc/gcc/diagnostic-global-context.cc:787
// 0xb19dfd fancy_abort(char const*, int, char const*)
// /src/gcc/gcc/diagnostics/context.cc:1813
// 0x945e29 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
// /src/gcc/gcc/rtl-error.cc:108
// 0x945e4f _fatal_insn_not_found(rtx_insn const*, char const*, int, char
const*)
// /src/gcc/gcc/rtl-error.cc:118
// 0x9447db extract_constrain_insn(rtx_insn*)
// /src/gcc/gcc/recog.cc:2856
// 0x10bb727 check_rtl
// /src/gcc/gcc/lra.cc:2246
// 0x10bfae5 lra(_IO_FILE*, int)
// /src/gcc/gcc/lra.cc:2698
// 0x1072e57 do_reload
// /src/gcc/gcc/ira.cc:6098
// 0x1072e57 execute
// /src/gcc/gcc/ira.cc:6286
// -quiet test.c -quiet -dumpbase test.c -dumpbase-ext .c -mlittle-endian
-mabi=lp64 -freport-bug -o - -frandom-seed=0 -fdump-noaddr
// Please submit a full bug report, with preprocessed source.
// Please include the complete backtrace with any bug report.
// See <https://gcc.gnu.org/bugs/> for instructions.
// /opt/cross/libexec/gcc/aarch64-linux-gnu/17.0.0/cc1 -quiet test.c -quiet
-dumpbase test.c -dumpbase-ext .c -mlittle-endian -mabi=lp64 -freport-bug -o -
-frandom-seed=0 -fdump-noaddr
# 0 "test.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "test.c"
__int128 f(__int128 v)
{
register __int128 x __asm__("x30") = v;
__asm__ volatile("" : "+r"(x));
return x;
}
```
Expected: an error at the declaration, since the pair x30:x31 includes SP,
e.g.:
Trunk ICEs at all optimization levels. GCC 16.1 and 13.3 ICE at -O1 and above.
Compiler Explorer (GCC trunk): https://godbolt.org/z/c3Kf1xv94