[PATCH v2 2/2] VN: Fix VN ICE for large _BitInt types

Kito Cheng kito.cheng@sifive.com
Mon Jan 5 02:55:53 GMT 2026


gcc.dg/torture/bitint-18.c triggers an ICE in push_partial_def when
compiling for RISC-V with -O2.  The issue occurs because
build_nonstandard_integer_type cannot handle bit widths larger than
MAX_FIXED_MODE_SIZE.  Bail out early for such cases.

gcc/ChangeLog:

	* tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def): Bail out
	for BITINT_TYPE when maxsizei exceeds MAX_FIXED_MODE_SIZE.
---
 gcc/tree-ssa-sccvn.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 0c519cf4c21..e931a227afd 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -2315,7 +2315,17 @@ vn_walk_cb_data::push_partial_def (pd_data pd,
   /* Make sure to interpret in a type that has a range covering the whole
      access size.  */
   if (INTEGRAL_TYPE_P (vr->type) && maxsizei != TYPE_PRECISION (vr->type))
-    type = build_nonstandard_integer_type (maxsizei, TYPE_UNSIGNED (type));
+    {
+      if (TREE_CODE (vr->type) == BITINT_TYPE
+	  && maxsizei > MAX_FIXED_MODE_SIZE)
+	{
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+	    fprintf (dump_file, "Failed to combine %u partial definitions "
+		     "(exceeds MAX_FIXED_MODE_SIZE)\n", ndefs);
+	  return (void *)-1;
+	}
+      type = build_nonstandard_integer_type (maxsizei, TYPE_UNSIGNED (type));
+    }
   tree val;
   if (BYTES_BIG_ENDIAN)
     {
-- 
2.52.0



More information about the Gcc-patches mailing list