On Thu, Jun 19, 2025 at 05:59:10PM +0800, Yang Yujie wrote: > --- a/gcc/expr.cc > +++ b/gcc/expr.cc > @@ -11268,6 +11268,10 @@ expand_expr_real_1 (tree exp, rtx target, > machine_mode tmode, > tree ssa_name = NULL_TREE; > gimple *g; > > + type = TREE_TYPE (exp); > + mode = TYPE_MODE (type); > + unsignedp = TYPE_UNSIGNED (type); > + > /* Some ABIs define padding bits in _BitInt uninitialized. Normally, RTL > expansion sign/zero extends integral types with less than mode precision > when reading from bit-fields and after arithmetic operations (see > @@ -11278,8 +11282,10 @@ expand_expr_real_1 (tree exp, rtx target, > machine_mode tmode, > objects in memory, or function arguments, return value). Because we > internally extend after arithmetic operations, we can avoid doing that > when reading from SSA_NAMEs of vars. */ > + > #define EXTEND_BITINT(expr) \ > ((TREE_CODE (type) == BITINT_TYPE \ > + && !bitint_type_info.extended \ > && reduce_bit_field > \ > && mode != BLKmode > \ > && modifier != EXPAND_MEMORY \ > @@ -11288,9 +11294,13 @@ expand_expr_real_1 (tree exp, rtx target, > machine_mode tmode, > && modifier != EXPAND_CONST_ADDRESS) \ > ? reduce_to_bit_field_precision ((expr), NULL_RTX, type) : (expr)) > > - type = TREE_TYPE (exp); > - mode = TYPE_MODE (type); > - unsignedp = TYPE_UNSIGNED (type); > + struct bitint_info bitint_type_info; > + if (TREE_CODE (type) == BITINT_TYPE) > + { > + bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), > + &bitint_type_info); > + gcc_assert (ok); > + }
This needs to be cached, having the target hook being called for expansion of anything with bitint type is too costly. Jakub