Hello,
This patch fixes PR target/120144, which causes an ICE when building libstdc++
for mips64-elf.
This issue is caused by MAX_FIXED_MODE_SIZE being incorrectly defined as
MIPS_LONG_DOUBLE_TYPE_SIZE which doesn't account for MIPS supporting TImode.
This patch updates the definition with the fix suggested by Andrew in the
bug report.
I have tested the patch by cross-compiling from x86_64-pc-linux-gnu to
mips64-elf and verified the fix with the included test case. There were no new
regressions in my testing. This also appears to fix an additional 287 gcc tests
and 4 g++ tests for mips64-elf. I am a first-time contributor and do not have
write access, so I would appreciate if someone could commit this on my behalf
if it looks good.
Thanks,
Carter Rennick
---
From f9bd03705a40508abc0937a1847f9d53aef26e0f Mon Sep 17 00:00:00 2001
From: Carter Rennick<[email protected]>
Date: Sat, 7 Mar 2026 18:01:50 +0000
Subject: [PATCH] mips: Fix ICE on mips64-elf by correcting MAX_FIXED_MODE_SIZE
[PR120144]
The original definition of MAX_FIXED_MODE_SIZE did not account for MIPS
supporting TImode, which causes an internal compiler error when building
libstdc++.
This patch updates MAX_FIXED_MODE_SIZE to correctly support TImode and DImode.
PR target/120144
gcc/ChangeLog:
* config/mips/mips.h (MAX_FIXED_MODE_SIZE): Redefined to use
GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
gcc/testsuite/ChangeLog:
* gcc.target/mips/pr120144.c: New test.
Signed-off-by: Carter Rennick<[email protected]>
---
gcc/config/mips/mips.h | 2 +-
gcc/testsuite/gcc.target/mips/pr120144.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/mips/pr120144.c
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index f52d0d2358c..535e10b8844 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -1708,7 +1708,7 @@ FP_ASM_SPEC "\
/* long double is not a fixed mode, but the idea is that, if we
support long double, we also want a 128-bit integer type. */
-#define MAX_FIXED_MODE_SIZE MIPS_LONG_DOUBLE_TYPE_SIZE
+#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
/* Width in bits of a pointer. */
#ifndef POINTER_SIZE
diff --git a/gcc/testsuite/gcc.target/mips/pr120144.c
b/gcc/testsuite/gcc.target/mips/pr120144.c
new file mode 100644
index 00000000000..e254771ea78
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/pr120144.c
@@ -0,0 +1,8 @@
+/* PR target/120144 */
+/* { dg-do compile } */
+/* { dg-require-effective-target int128 } */
+
+int f(unsigned __int128 t)
+{
+ return __builtin_clzg(t);
+}
--
2.53.0