https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126891
Bug ID: 126891
Summary: [PPC] ICE in copy_to_mode_reg for
__builtin_set_fpscr_drn with variable argument
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: stuzyf at 163 dot com
Target Milestone: ---
Target: PowerPC64LE
The following valid code triggers an internal compiler error with GCC trunk on
powerpc64le:
Reproducer:
https://godbolt.org/z/T1ohj8b64
```
int main ()
{
int a = (8);
__builtin_set_fpscr_drn(a);
}
```
Compilation fails during RTL expansion with:
```
during RTL pass: expand
<source>: In function 'main':
<source>:4:5: internal compiler error: in copy_to_mode_reg, at explow.cc:657
4 | __builtin_set_fpscr_drn(a);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
0x24348e2 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x24292cf internal_error(char const*, ...)
???:0
0x9d0351 fancy_abort(char const*, int, char const*)
???:0
0x17a8d8f rs6000_expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode,
int)
???:0
0xd08e9c expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
/cefs/27/27b3a74bd07f4fee3b560737_powerpc64le_gcc-trunk-20260706/powerpc64le-unknown-linux-gnu/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/17.0.0/cc1
-quiet -iprefix
/cefs/27/27b3a74bd07f4fee3b560737_powerpc64le_gcc-trunk-20260706/powerpc64le-unknown-linux-gnu/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/17.0.0/
-isysroot
/cefs/27/27b3a74bd07f4fee3b560737_powerpc64le_gcc-trunk-20260706/powerpc64le-unknown-linux-gnu/bin/../powerpc64le-unknown-linux-gnu/sysroot
<source> -quiet -dumpdir /app/ -dumpbase output.c -dumpbase-ext .c -g
-fdiagnostics-color=always -fno-verbose-asm -o /app/output.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```
The ICE is reproducible with GCC trunk and can be traced back to at least GCC
12.1.