]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
bitint: Allow mode promotion of _BitInt types
authorYang Yujie <yangyujie@loongson.cn>
Tue, 5 Aug 2025 10:52:27 +0000 (12:52 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Aug 2025 10:52:27 +0000 (12:52 +0200)
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.

gcc/explow.cc

index 7799a98053bdf4caa602272d1f6926d548a86927..8f8ca7f011e0b2b5612e6c3988efce81ef15625c 100644 (file)
@@ -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.  */