For targets that set the "extended" flag in TARGET_C_BITINT_TYPE_INFO, we assume small _BitInts to be internally extended after arithmetic operations. In this case, an extra extension during RTL expansion can be avoided.
gcc/ChangeLog: * expr.cc (expand_expr_real_1): Do not call reduce_to_bit_field_precision if the target assume the _BitInt results to be already extended. (EXTEND_BITINT): Same. * expr.h (bitint_extended): Declare the cache variable. * function.cc (prepare_function_start): Initialize it. --- gcc/expr.cc | 12 ++++++++++++ gcc/expr.h | 4 ++++ gcc/function.cc | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/gcc/expr.cc b/gcc/expr.cc index ac4fdfaa218..97d833a33a6 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -76,6 +76,10 @@ along with GCC; see the file COPYING3. If not see the same indirect address eventually. */ int cse_not_expected; +/* Cache of the "extended" flag in the target's _BitInt description + for use during expand. */ +int bitint_extended; + static bool block_move_libcall_safe_for_call_parm (void); static bool emit_block_move_via_pattern (rtx, rtx, rtx, unsigned, unsigned, HOST_WIDE_INT, unsigned HOST_WIDE_INT, @@ -11280,6 +11284,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, when reading from SSA_NAMEs of vars. */ #define EXTEND_BITINT(expr) \ ((TREE_CODE (type) == BITINT_TYPE \ + && !bitint_extended \ && reduce_bit_field \ && mode != BLKmode \ && modifier != EXPAND_MEMORY \ @@ -11291,6 +11296,13 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, type = TREE_TYPE (exp); mode = TYPE_MODE (type); unsignedp = TYPE_UNSIGNED (type); + if (bitint_extended == -1 && TREE_CODE (type) == BITINT_TYPE) + { + struct bitint_info info; + bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), &info); + gcc_assert (ok); + bitint_extended = info.extended; + } treeop0 = treeop1 = treeop2 = NULL_TREE; if (!VL_EXP_CLASS_P (exp)) diff --git a/gcc/expr.h b/gcc/expr.h index 53ab625787e..060151df010 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -388,4 +388,8 @@ extern void expand_crc_table_based (rtx, rtx, rtx, rtx, machine_mode); extern void expand_reversed_crc_table_based (rtx, rtx, rtx, rtx, machine_mode, void (*) (rtx *)); +/* Cache of the "extended" flag in the target's _BitInt description + for use during expand. */ +extern int bitint_extended; + #endif /* GCC_EXPR_H */ diff --git a/gcc/function.cc b/gcc/function.cc index 48167b0c207..502135c6f58 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -4965,6 +4965,10 @@ prepare_function_start (void) /* Indicate we have no need of a frame pointer yet. */ frame_pointer_needed = 0; + + /* Reset the cache of the "extended" flag in the target's + _BitInt info struct. */ + bitint_extended = -1; } void -- 2.46.0