Hi Suwa-san,
On Tue, Mar 10, 2026 at 3:30 AM Takayuki 'January June' Suwa
<[email protected]> wrote:
>
> Previously, in 1eefa6e0c84e3008ed7ac44d08a8e5206038fb33 and a series of
> subsequent commits, we added a target-specific optimization pass
> 'xt_largeconst' right after postreload to convert assignments of numeric
> constants that don't fit into immediate fields to a more efficient
> implementation than the standard one (references to literal pool entries),
> if available.
>
> However, the processes performed in this pass are a mixture of essential
> and optional ones (such as optimizations), which is not good in terms of
> structure or execution efficiency. Additionally, large numeric constant
> assignments may be emitted after this pass, for example during stack frame
> construction in function prologue.
>
> To address these issues, this patch splits the processing in this pass
> into two parts:
>
> - places the mandatory processing (i.e., restoring delegitimized forms
> of large numeric constant assignments to valid ones) immediately after
> postreload, and
> - places the rest, optional processing (i.e., optimizations) immediately
> before regrename, which a reasonable location after pro_and_epilogue
> and before sched2.
>
> gcc/ChangeLog:
>
> * config/xtensa/xtensa-passes.def (pass_xtensa_largeconst):
> Rename to pass_xtensa_largeconst1.
> (pass_xtensa_largeconst2): New target-specific pass.
> * config/xtensa/xtensa-protos.h (make_pass_xtensa_largeconst):
> Rename to make_pass_xtensa_largeconst1.
> (make_pass_xtensa_largeconst2): New function prototype.
> * config/xtensa/xtensa.cc (do_largeconst):
> Rename it to do_largeconst1 and leave only the mandatory insn
> transformation process.
> (do_largeconst2): New function that inherits the optional insn
> transformation processes from the old do_largeconst.
> (rest_of_handle_largeconst):
> Rename to rest_of_handle_largeconst1 and change to call
> do_largeconst1.
> (rest_of_handle_largeconst2): New function that calls
> do_largeconst2.
> (pass_data_xtensa_largeconst)
> Rename to pass_data_xtensa_largeconst1.
> (pass_xtensa_largeconst):
> Rename to pass_xtensa_largeconst1 and change to call
> rest_of_handle_largeconst1.
> (pass_data_xtensa_largeconst2): New opt_pass data.
> (pass_xtensa_largeconst2):
> New rtl_opt_pass that runs rest_of_handle_largeconst2 when non-
> debug optimizations are enabled.
> (make_pass_xtensa_largeconst):
> Rename to make_pass_xtensa_largeconst1.
> (make_pass_xtensa_largeconst2): New function definition.
> ---
> gcc/config/xtensa/xtensa-passes.def | 3 +-
> gcc/config/xtensa/xtensa-protos.h | 3 +-
> gcc/config/xtensa/xtensa.cc | 120 +++++++++++++++++++++-------
> 3 files changed, 94 insertions(+), 32 deletions(-)
This change introduces ICEs when building target libraries with
backtraces that look like this:
/home/jcmvbkbc/ws/tensilica/gcc/gcc/libstdc++-v3/src/c++20/tzdb.cc:1056:3:
error: insn does not satisfy its constraints:
1056 | }
| ^
(insn 731 730 10795 41 (set (reg:DI 10 a10 [612])
(const_int -1096193779200 [0xffffff00c5c25a00]))
"/home/jcmvbkbc/ws/tensilica/gcc/gcc/libstdc++-v3/src/c++20/tzdb.cc":815:18
70 {movdi_internal}
(expr_list:REG_EQUIV (const_int -1096193779200 [0xffffff00c5c25a00])
(nil)))
during RTL pass: ce3
/home/jcmvbkbc/ws/tensilica/gcc/gcc/libstdc++-v3/src/c++20/tzdb.cc:1056:3:
internal compiler error: in extract_constrain_insn_cached, at
recog.cc:2805
0x209ffad internal_error(char const*, ...)
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/diagnostic-global-context.cc:787
0x9a0cf8 fancy_abort(char const*, int, char const*)
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/diagnostics/context.cc:1813
0x83c122 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/rtl-error.cc:108
0x83c148 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/rtl-error.cc:118
0x83ac3c extract_constrain_insn_cached(rtx_insn*)
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/recog.cc:2805
0x1dbac5f insn_default_length(rtx_insn*)
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/config/xtensa/xtensa.md:442
0x17607e7 xtensa_insn_cost
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/config/xtensa/xtensa.cc:4606
0x1ee4df7 cheap_bb_rtx_cost_p
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ifcvt.cc:176
0x1eedf76 find_if_case_1
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ifcvt.cc:5775
0x1eedf76 find_if_header
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ifcvt.cc:5191
0x1eedf76 if_convert
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ifcvt.cc:6322
0x1eefc4d execute
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ifcvt.cc:6475
--
Thanks.
-- Max