On Tue, Jun 18, 2024 at 7:56 PM Takayuki 'January June' Suwa
<jjsuwa_sys3...@yahoo.co.jp> wrote:
>
> The previous constant synthesis logic had some issues that were non-fatal
> but worth considering:
>
> - It didn't work with DFmode literals, because those were cast to SImode
>    rather SFmode when splitting into two natural-width words by
>    split_double().
>
> - It didn't work with large literals when TARGET_AUTO_LITPOOLS was enabled,
>    because those were relaxed MOVI immediates rather references to literal
>    pool entries,
>
> - It didn't take into account that when literals with the same RTL
>    representation are pooled multiple times within a function, those entries
>    are shared (especially important when optimizing for size).
>
> This patch addresses the above issues by making appropriate tweaks to the
> constant synthesis logic.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa-protos.h (xtensa_constantsynth):
>         Change the second argument from HOST_WIDE_INT to rtx.
>         * config/xtensa/xtensa.cc (#include):
>         Add "context.h" and "pass_manager.h".
>         (machine_function): Add a new hash_map field "litpool_usage".
>         (xtensa_constantsynth): Make "src" (the second operand) accept
>         RTX literal instead of its value, and treat both bare and pooled
>         SI/SFmode literals equally by bit-exact canonicalization into
>         CONST_INT RTX internally.  And then, make avoid synthesis if
>         such multiple identical canonicalized literals are found in same
>         function when optimizing for size.  Finally, for literals where
>         synthesis is not possible or has been avoided, re-emit "move"
>         RTXes with canonicalized ones to increase the chances of sharing
>         literal pool entries.
>         * config/xtensa/xtensa.md (split patterns for constant synthesis):
>         Change to simply invoke xtensa_constantsynth() as mentioned above,
>         and add new patterns for when TARGET_AUTO_LITPOOLS is enabled.
> ---
>   gcc/config/xtensa/xtensa-protos.h |  2 +-
>   gcc/config/xtensa/xtensa.cc       | 75 ++++++++++++++++++++++++++++---
>   gcc/config/xtensa/xtensa.md       | 56 ++++++++++++++---------
>   3 files changed, 103 insertions(+), 30 deletions(-)

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.

-- 
Thanks.
-- Max

Reply via email to