From: Yang Yujie Date: Tue, 5 Aug 2025 10:52:27 +0000 (+0200) Subject: bitint: Allow mode promotion of _BitInt types X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9b96c63d9f1c5cb4a60ca7c8faa95db8ef7a8b6;p=thirdparty%2Fgcc.git bitint: Allow mode promotion of _BitInt types For targets that treat small _BitInts like the fundamental integral types, we should allow their machine modes to be promoted in the same way. * explow.cc (promote_function_mode): Add a case for small/medium _BitInts. (promote_mode): Same. --- diff --git a/gcc/explow.cc b/gcc/explow.cc index 7799a98053b..8f8ca7f011e 100644 --- a/gcc/explow.cc +++ b/gcc/explow.cc @@ -854,6 +854,18 @@ promote_function_mode (const_tree type, machine_mode mode, int *punsignedp, switch (TREE_CODE (type)) { + case BITINT_TYPE: + if (TYPE_MODE (type) == BLKmode) + return mode; + + struct bitint_info info; + bool ok; + ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), &info); + gcc_assert (ok); + + if (!info.extended) + return mode; + /* FALLTHRU */ case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: case REAL_TYPE: case OFFSET_TYPE: case FIXED_POINT_TYPE: case POINTER_TYPE: case REFERENCE_TYPE: @@ -893,6 +905,18 @@ promote_mode (const_tree type ATTRIBUTE_UNUSED, machine_mode mode, switch (code) { + case BITINT_TYPE: + if (TYPE_MODE (type) == BLKmode) + return mode; + + struct bitint_info info; + bool ok; + ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), &info); + gcc_assert (ok); + + if (!info.extended) + return mode; + /* FALLTHRU */ case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: case REAL_TYPE: case OFFSET_TYPE: case FIXED_POINT_TYPE: /* Values of these types always have scalar mode. */