On Sun, Mar 15, 2026 at 2:32 AM Takayuki 'January June' Suwa
<[email protected]> wrote:
>
> This patch adds a new 2-instructions constant synthesis method:
>
>   - A positive integer value that, despite left-shifting the leading 0 bits,
>     becomes a negative number that still fits into a signed 12-bit
>       => "MOVI(.N) Ax, simm12" + "SRLI Ax, Ax, 1...10"
>
>      /* example */
>      int test(void) {
>        return 0x1FFFFF55;  /* 0b00011111111111111111111101010101 */
>      }
>
>      ;; before (-O1 -mextra-l32r-costs=1)
>         .literal_position
>         .literal .LC0, 536870741
>      test:
>         entry   sp, 32
>         l32r    a2, .LC0
>         retw.n
>
>      ;; after (-O1 -mextra-l32r-costs=1)
>      test:
>         entry   sp, 32
>         movi    a2, -0x558
>         srli    a2, a2, 3
>         retw.n
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.cc
>         (constantsynth_method_lshr_mi12b): New.
>         (constantsynth_methods): Add constantsynth_method_lshr_mi12b.
> ---
>   gcc/config/xtensa/xtensa.cc | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)

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

-- 
Thanks.
-- Max

Reply via email to