[COMMITTED] gcc: xtensa: use salt/saltu in xtensa_expand_scc

2023-09-14 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/predicates.md (xtensa_cstoresi_operator): Add unsigned comparisons. * config/xtensa/xtensa.cc (xtensa_expand_scc): Add code generation of salt/saltu instructions. * config/xtensa/xtensa.h (TARGET_SALT): New macro. *

Re: [PATCH] xtensa: Optimize several boolean evaluations of EQ/NE against constant zero

2023-09-13 Thread Max Filippov via Gcc-patches
On Fri, Sep 8, 2023 at 1:49 AM Takayuki 'January June' Suwa wrote: > > An idiomatic implementation of boolean evaluation of whether a register is > zero or not in Xtensa is to assign 0 and 1 to the temporary and destination, > and then issue the MOV[EQ/NE]Z machine instruction > (See 8.3.2

[RFC] gcc: xtensa: use salt/saltu in xtensa_expand_scc

2023-09-07 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/predicates.md (xtensa_cstoresi_operator): Add unsigned comparisons. * config/xtensa/xtensa.cc (xtensa_expand_scc): Add code generation of salt/saltu instructions. * config/xtensa/xtensa.h (TARGET_SALT): New macro. *

Re: [PATCH] xtensa: Optimize boolean evaluation when SImode EQ/NE to zero if TARGET_MINMAX

2023-09-06 Thread Max Filippov via Gcc-patches
On Tue, Sep 5, 2023 at 2:29 AM Takayuki 'January June' Suwa wrote: > > This patch optimizes the boolean evaluation for equality to 0 in SImode > using the MINU (Minimum Value Unsigned) machine instruction available > when TARGET_MINMAX is configured, for example, (x != 0) to MINU(x, 1) > and (x

Re: [PATCH] xtensa: Optimize boolean evaluation when SImode EQ/NE to zero if TARGET_MINMAX

2023-09-06 Thread Max Filippov via Gcc-patches
On Tue, Sep 5, 2023 at 9:24 PM Takayuki 'January June' Suwa wrote: > On 2023/09/06 8:01, Max Filippov wrote: > > On Tue, Sep 5, 2023 at 2:29 AM Takayuki 'January June' Suwa > > wrote: > >> ;; after (prereq. TARGET_MINMAX) > >> test0: > >> movi.n a9, 1 > >> minua2,

Re: [PATCH] xtensa: Optimize boolean evaluation when SImode EQ/NE to zero if TARGET_MINMAX

2023-09-05 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Tue, Sep 5, 2023 at 2:29 AM Takayuki 'January June' Suwa wrote: > > This patch optimizes the boolean evaluation for equality to 0 in SImode > using the MINU (Minimum Value Unsigned) machine instruction available > when TARGET_MINMAX is configured, for example, (x != 0) to MINU(x,

Re: [PATCH 2/3] gcc: xtensa: use dynconfig settings as builtin-macros

2023-07-20 Thread Max Filippov via Gcc-patches
On Thu, Jul 20, 2023 at 10:54 AM Alexey Lapshin wrote: > Please consider to review another two pathes then. > This would be nice to have it in upstream Sure, it's going to take some time though as I need to take a good look, and maybe I'll come back with some change proposals. -- Thanks. --

Re: [PATCH 2/3] gcc: xtensa: use dynconfig settings as builtin-macros

2023-07-20 Thread Max Filippov via Gcc-patches
On Thu, Jul 20, 2023 at 10:45 AM Alexey Lapshin wrote: > > On Thu, 2023-07-20 at 08:25 -0700, Max Filippov wrote: > > But it defines them with their respective values. > > Just notice that it adds two leading underscores in front of the names. > > Why builtin macros were defined with prefix? >

Re: [PATCH 2/3] gcc: xtensa: use dynconfig settings as builtin-macros

2023-07-20 Thread Max Filippov via Gcc-patches
On Thu, Jul 20, 2023 at 9:10 AM Alexey Lapshin wrote: > I see now, thanks for the explanation, I will try to rebuild toolchain > without this particular patch. > BTW, what do you thing about placing config from newlib overlay to dynconfig? That's the right thing to do. Bonus points for keeping

Re: [PATCH 2/3] gcc: xtensa: use dynconfig settings as builtin-macros

2023-07-20 Thread Max Filippov via Gcc-patches
On Thu, Jul 20, 2023 at 8:12 AM Alexey Lapshin wrote: > > Oops, missed this loop while implementing... > > I had a problem with building esp chips multilib until added my changes. > > This loop looks like just defines a macro without value. But it defines them with their respective values. Just

Re: [PATCH 2/3] gcc: xtensa: use dynconfig settings as builtin-macros

2023-07-20 Thread Max Filippov via Gcc-patches
On Thu, Jul 20, 2023 at 7:37 AM Alexey Lapshin wrote: > > gcc/ > * config/xtensa/xtensa.h (XCHAL_HAVE_BE, XCHAL_HAVE_DENSITY, > XCHAL_HAVE_CONST16, XCHAL_HAVE_ABS, XCHAL_HAVE_ADDX, > XCHAL_HAVE_L32R, XSHAL_USE_ABSOLUTE_LITERALS, >

Re: [PATCH] xtensa: Use HARD_REG_SET instead of bare integer

2023-07-04 Thread Max Filippov via Gcc-patches
On Mon, Jul 3, 2023 at 5:57 PM Takayuki 'January June' Suwa wrote: > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (machine_function, xtensa_expand_prologue): > Change to use HARD_REG_BIT and its macros. > * config/xtensa/xtensa.md > (peephole2: regmove

Re: [PATCH 1/2] xtensa: Fix missing mode warning in "*eqne_INT_MIN"

2023-07-02 Thread Max Filippov via Gcc-patches
On Sat, Jul 1, 2023 at 10:21 AM Takayuki 'January June' Suwa wrote: > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (*eqne_INT_MIN): > Add missing ":SI" to the match_operator. > --- > gcc/config/xtensa/xtensa.md | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Regtested

Re: [PATCH 2/2] xtensa: The use of CLAMPS instruction also requires TARGET_MINMAX, as well as TARGET_CLAMPS

2023-07-02 Thread Max Filippov via Gcc-patches
On Sat, Jul 1, 2023 at 10:21 AM Takayuki 'January June' Suwa wrote: > > Because both smin and smax requiring TARGET_MINMAX are essential to the > RTL representation. > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (xtensa_match_CLAMPS_imms_p): > Simplify. > *

Re: [PATCH 2/2] xtensa: constantsynth: Add new 2-insns synthesis pattern

2023-06-18 Thread Max Filippov via Gcc-patches
On Sun, Jun 18, 2023 at 12:10 AM Takayuki 'January June' Suwa wrote: > > This patch adds a new 2-instructions constant synthesis pattern: > > - A non-negative square value that root can fit into a signed 12-bit: > => "MOVI(.N) Ax, simm12" + "MULL Ax, Ax, Ax" > > Due to the execution cost of

Re: [PATCH 1/2] xtensa: Remove TARGET_MEMORY_MOVE_COST hook

2023-06-18 Thread Max Filippov via Gcc-patches
On Sun, Jun 18, 2023 at 12:10 AM Takayuki 'January June' Suwa wrote: > > It used to always return a constant 4, which is same as the default > behavior, but doesn't take into account the effects of secondary > reloads. > > Therefore, the implementation of this target hook is removed. > >

Re: [PATCH v2] xtensa: Optimize boolean evaluation or branching when EQ/NE to zero in S[IF]mode

2023-06-05 Thread Max Filippov via Gcc-patches
On Mon, Jun 5, 2023 at 8:15 AM Max Filippov wrote: > > Hi Suwa-san, > > On Mon, Jun 5, 2023 at 2:37 AM Takayuki 'January June' Suwa > wrote: > > > > This patch optimizes the boolean evaluation of EQ/NE against zero > > by adding two insn_and_split patterns similar to SImode conditional > >

Re: [PATCH v2] xtensa: Optimize boolean evaluation or branching when EQ/NE to zero in S[IF]mode

2023-06-05 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, Jun 5, 2023 at 2:37 AM Takayuki 'January June' Suwa wrote: > > This patch optimizes the boolean evaluation of EQ/NE against zero > by adding two insn_and_split patterns similar to SImode conditional > store: > > "eq_zero": > op0 = (op1 == 0) ? 1 : 0; > op0 =

Re: [PATCH] xtensa: Optimize boolean evaluation or branching when EQ/NE to INT_MIN

2023-06-04 Thread Max Filippov via Gcc-patches
On Sat, Jun 3, 2023 at 3:52 PM Takayuki 'January June' Suwa wrote: > > This patch optimizes both the boolean evaluation of and the branching of > EQ/NE against INT_MIN (-2147483648), by taking advantage of the specifi- > cation the ABS machine instruction on Xtensa returns INT_MIN iff INT_MIN, >

Re: [PATCH] xtensa: Optimize boolean evaluation or branching when EQ/NE to zero in S[IF]mode

2023-06-04 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Sat, Jun 3, 2023 at 2:55 AM Takayuki 'January June' Suwa wrote: > > This patch optimizes the boolean evaluation of EQ/NE against zero > by adding two insn_and_split patterns similar to SImode conditional > store: > > "eq_zero": > op0 = (op1 == 0) ? 1 : 0; > op0 =

Re: [PATCH 2/3 v3] xtensa: Add 'adddi3' and 'subdi3' insn patterns

2023-06-01 Thread Max Filippov via Gcc-patches
On Wed, May 31, 2023 at 11:01 PM Takayuki 'January June' Suwa wrote: > More optimized than the default RTL generation. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (adddi3, subdi3): > New RTL generation patterns implemented according to the instruc- > tion idioms

Re: [PATCH 2/3 v3] xtensa: Add 'adddi3' and 'subdi3' insn patterns

2023-06-01 Thread Max Filippov via Gcc-patches
On Wed, May 31, 2023 at 11:01 PM Takayuki 'January June' Suwa wrote: > More optimized than the default RTL generation. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (adddi3, subdi3): > New RTL generation patterns implemented according to the instruc- > tion idioms

Re: [PATCH 1/3] xtensa: Improve "*shlrd_reg" insn pattern and its variant

2023-05-31 Thread Max Filippov via Gcc-patches
On Tue, May 30, 2023 at 2:27 AM Takayuki 'January June' Suwa wrote: > > The insn "*shlrd_reg" shifts two registers with a funnel shifter by the > third register to get a single word result: > > reg0 = (reg1 SHIFT_OP0 reg3) BIT_JOIN_OP (reg2 SHIFT_OP1 (32 - reg3)) > > where the funnel left shift

Re: [PATCH 2/3 v2] xtensa: Add 'adddi3' and 'subdi3' insn patterns

2023-05-31 Thread Max Filippov via Gcc-patches
On Tue, May 30, 2023 at 2:50 AM Takayuki 'January June' Suwa wrote: > > Resubmitting the correct one due to a mistake in merging order of fixes. > --- > More optimized than the default RTL generation. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (adddi3, subdi3): > New RTL

Re: [PATCH 3/3 v2] xtensa: Optimize 'cstoresi4' insn pattern

2023-05-30 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Tue, May 30, 2023 at 2:51 AM Takayuki 'January June' Suwa wrote: > > Resubmitting the correct one due to a mistake in merging order of fixes. > --- > This patch introduces more optimized implementations for the 6 cstoresi4 > insn comparison methods (eq/ne/lt/le/gt/ge, however,

Re: [PATCH 3/3] xtensa: Rework 'setmemsi' insn pattern

2023-05-26 Thread Max Filippov via Gcc-patches
On Thu, May 25, 2023 at 8:13 AM Takayuki 'January June' Suwa wrote: > > In order to reject voodoo estimation logic with lots of magic numbers, > this patch revises the code to measure the costs of the three memset > methods based on the actual emission size of the insn sequence > corresponding to

Re: [PATCH 2/3] xtensa: Add 'subtraction from constant' insn pattern

2023-05-26 Thread Max Filippov via Gcc-patches
On Thu, May 25, 2023 at 8:13 AM Takayuki 'January June' Suwa wrote: > > This patch makes try to eliminate using temporary pseudo for > '(minus:SI (const_int) (reg:SI))' if the addition of negative constant > value can be emitted in a single machine instruction. > > /* example */ > int

Re: [PATCH 1/3] xtensa: Addendum of the commit e33d2dcb463161a110ac345a451132ce8b2b23d9

2023-05-26 Thread Max Filippov via Gcc-patches
On Thu, May 25, 2023 at 8:13 AM Takayuki 'January June' Suwa wrote: > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (*extzvsi-1bit_ashlsi3): > Retract excessive line folding, and correct the value of > the "length" insn attribute related to TARGET_DENSITY. >

Re: [PATCH 2/2] xtensa: Merge '*addx' and '*subx' insn patterns into one

2023-05-23 Thread Max Filippov via Gcc-patches
On Mon, May 22, 2023 at 12:06 AM Takayuki 'January June' Suwa wrote: > > By making use of the 'addsub_operator' added in the last patch. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (*addsubx): Rename from '*addx', > and change to also accept '*subx' pattern. >

Re: [PATCH v2] xtensa: Optimize '(x & CST1_POW2) != 0 ? CST2_POW2 : 0'

2023-05-23 Thread Max Filippov via Gcc-patches
On Mon, May 22, 2023 at 10:48 PM Takayuki 'January June' Suwa wrote: > > On 2023/05/23 11:27, Max Filippov wrote: > > Hi Suwa-san, > > Hi! > > > This change introduces a bunch of test failures on big endian configuration. > > I believe that's because the starting bit position for zero_extract is

Re: [PATCH 1/2] xtensa: Optimize '(x & CST1_POW2) != 0 ? CST2_POW2 : 0'

2023-05-22 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, May 22, 2023 at 12:06 AM Takayuki 'January June' Suwa wrote: > > This patch decreses one machine instruction from "single bit extraction > with shifting" operation, and tries to eliminate the conditional > branch if CST2_POW2 doesn't fit into signed 12 bits with the help >

Re: [PATCH] xtensa: Make full transition to LRA

2023-05-10 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, May 8, 2023 at 6:38 AM Takayuki 'January June' Suwa wrote: > > gcc/ChangeLog: > > * config/xtensa/constraints.md (R, T, U): > Change define_constraint to define_memory_constraint. > * config/xtensa/xtensa.cc > (xtensa_lra_p, TARGET_LRA_P):

[COMMITTED 2/2] gcc: xtensa: add -m[no-]strict-align option

2023-04-19 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa-opts.h: New header. * config/xtensa/xtensa.h (STRICT_ALIGNMENT): Redefine as xtensa_strict_align. * config/xtensa/xtensa.cc (xtensa_option_override): When -m[no-]strict-align is not specified in the command line set

[COMMITTED 1/2] gcc: xtensa: add data alignment properties to dynconfig

2023-04-19 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa-dynconfig.cc (xtensa_get_config_v4): New function. include/ * xtensa-dynconfig.h (xtensa_config_v4): New struct. (XCHAL_DATA_WIDTH, XCHAL_UNALIGNED_LOAD_EXCEPTION) (XCHAL_UNALIGNED_STORE_EXCEPTION, XCHAL_UNALIGNED_LOAD_HW)

Re: [PATCH] xtensa: Fix for enabling LRA

2023-03-13 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Tue, Mar 7, 2023 at 10:04 PM Takayuki 'January June' Suwa wrote: > > This patch makes LRA well with some exceptions > (e.g. MI thunk generation due to pretending reload_completed). > > gcc/ChangeLog: > > * config/xtensa/constraints.md (R, T, U): > Change

[COMMITTED] xtensa: add .note.GNU-stack section on linux

2023-03-13 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/linux.h (TARGET_ASM_FILE_END): New macro. libgcc/ * config/xtensa/crti.S: Add .note.GNU-stack section on linux. * config/xtensa/crtn.S: Likewise. * config/xtensa/lib1funcs.S: Likewise. * config/xtensa/lib2funcs.S: Likewise. ---

Re: [PATCH] xtensa: Remove REG_OK_STRICT and its derivatives

2023-03-13 Thread Max Filippov via Gcc-patches
On Sun, Mar 12, 2023 at 5:37 PM Takayuki 'January June' Suwa wrote: > > Because GO_IF_LEGITIMATE_ADDRESS was deprecated a long time ago > (see commit c6c3dba931548987c78719180e30ebc863404b89). > > gcc/ChangeLog: > > * config/xtensa/xtensa.h (REG_OK_STRICT, REG_OK_FOR_INDEX_P, >

[PATCH 1/2] gcc: xtensa: add data alignment properties to dynconfig

2023-02-28 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa-dynconfig.cc (xtensa_get_config_v4): New function. include/ * xtensa-dynconfig.h (xtensa_config_v4): New struct. (XCHAL_DATA_WIDTH, XCHAL_UNALIGNED_LOAD_EXCEPTION) (XCHAL_UNALIGNED_STORE_EXCEPTION, XCHAL_UNALIGNED_LOAD_HW)

[PATCH 2/2] gcc: xtensa: adjust STRICT_ALIGNMENT per hardware capabilities

2023-02-28 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa.h (STRICT_ALIGNMENT): Make it 0 when the hardware supports both unaligned loads and stores. --- gcc/config/xtensa/xtensa.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h

Re: [PATCH] xtensa: Make use of CLAMPS instruction if configured

2023-02-27 Thread Max Filippov via Gcc-patches
On Sun, Feb 26, 2023 at 9:27 AM Takayuki 'January June' Suwa wrote: > > This patch introduces the use of CLAMPS instruction when the instruction > is configured. > > /* example */ > int test(int a) { > if (a < -512) > return -512; > if (a > 511) > return 511; >

[PATCH] gcc: xtensa: add XCHAL_HAVE_{CLAMPS, DEPBITS, EXCLUSIVE, XEA3} to dynconfig

2023-02-27 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa-dynconfig.cc (xtensa_get_config_v2) (xtensa_get_config_v3): New functions. include/ * xtensa-dynconfig.h (xtensa_config_v3): New struct. (xtensa_get_config_v3): New declaration. (XCHAL_HAVE_CLAMPS, XCHAL_HAVE_DEPBITS,

Re: [PATCH] xtensa: Make use of CLAMPS instruction if configured

2023-02-26 Thread Max Filippov via Gcc-patches
On Sun, Feb 26, 2023 at 9:27 AM Takayuki 'January June' Suwa wrote: > This patch introduces the use of CLAMPS instruction when the instruction > is configured. Testing. > (Totally off-topic, but do you know anything about the SALT/SALTU > instructions? > I see them in the "Core Architecture

[COMMITTED] gcc: xtensa: fix PR target/108919

2023-02-25 Thread Max Filippov via Gcc-patches
gcc/ PR target/108919 * config/xtensa/xtensa-protos.h (xtensa_prepare_expand_call): Rename to xtensa_expand_call. * config/xtensa/xtensa.cc (xtensa_prepare_expand_call): Rename to xtensa_expand_call. (xtensa_expand_call): Emit the call and add a

Re: [PATCH] gcc: xtensa: fix PR target/108919

2023-02-25 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Sat, Feb 25, 2023 at 3:33 AM Takayuki 'January June' Suwa wrote: > On 2023/02/25 19:01, Max Filippov wrote: > > diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc > > index e52fba082550..babe7f0ebd68 100644 > > --- a/gcc/config/xtensa/xtensa.cc > > +++

[PATCH] gcc: xtensa: fix PR target/108919

2023-02-25 Thread Max Filippov via Gcc-patches
gcc/ PR target/108919 * config/xtensa/xtensa-protos.h (xtensa_prepare_expand_call): Rename to xtensa_expand_call. * config/xtensa/xtensa.cc (xtensa_prepare_expand_call): Rename to xtensa_expand_call. (xtensa_expand_call): Emit the call and add a

[COMMITTED 1/2] gcc: xtensa: rename xtensa-dynconfig.c and update its build rule

2023-02-23 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/t-xtensa (xtensa-dynconfig.o): Use $(COMPILE) and $(POSTCOMPILE) instead of manual dependency listing. * config/xtensa/xtensa-dynconfig.c: Rename to ... * config/xtensa/xtensa-dynconfig.cc: ... this. --- gcc/config/xtensa/t-xtensa

[COMMITTED 2/2] gcc: xtensa: update include style in xtensa-dynconfig.cc

2023-02-23 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa-dynconfig.cc (config.h, system.h) (coretypes.h, diagnostic.h, intl.h): Use "..." instead of <...> for the gcc-internal headers. --- gcc/config/xtensa/xtensa-dynconfig.cc | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff

Re: [PATCH 1/2] xtensa: Fix non-fatal regression introduced by b2ef02e8cbbaf95fee98be255f697f47193960ec

2023-02-23 Thread Max Filippov via Gcc-patches
On Thu, Feb 23, 2023 at 1:35 AM Max Filippov wrote: > > On Wed, Feb 22, 2023 at 7:42 PM Takayuki 'January June' Suwa > wrote: > > > > In commit b2ef02e8cbbaf95fee98be255f697f47193960ec, the sibling call > > insn included (use (reg:SI A0_REG)) to fix the problem, which added > > a USE chain

Re: [PATCH v7] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-02-23 Thread Max Filippov via Gcc-patches
On Thu, Feb 16, 2023 at 11:54 PM Takayuki 'January June' Suwa wrote: > > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that > the save

Re: [PATCH v5] xtensa: Eliminate unnecessary general-purpose reg-reg moves

2023-02-23 Thread Max Filippov via Gcc-patches
On Fri, Feb 17, 2023 at 8:43 PM Takayuki 'January June' Suwa wrote: > > Register-register move instructions that can be easily seen as > unnecessary by the human eye may remain in the compiled result. > For example: > > /* example */ > double test(double a, double b) { > return

Re: [PATCH] xtensa: Fix up fatal_error message strings in xtensa-dynconfig.c [PR108890]

2023-02-23 Thread Max Filippov via Gcc-patches
Hi Jakub, On Thu, Feb 23, 2023 at 2:34 AM Jakub Jelinek wrote: > The translation PR complains that these 4 messages from xtensa-dynconfig.c > are marked in po/gcc.pot as c-format (which doesn't allow %qs) while they > should be gcc-internal-format. > > The problem is in the manual translation of

[COMMITTED 2/2] xtensa: fix PR target/108876

2023-02-23 Thread Max Filippov via Gcc-patches
In commit b2ef02e8cbbaf95fee98be255f697f47193960ec, the sibling call insn included (use (reg:SI A0_REG)) to fix the problem, which added a USE chain unconditionally to the data flow of register A0 during the sibling call. As a result, df_regs_ever_live_p (A0_REG) returns true, so even if register

[COMMITTED 1/2] Revert "gcc: xtensa: fix PR target/108876"

2023-02-23 Thread Max Filippov via Gcc-patches
This reverts commit b2ef02e8cbbaf95fee98be255f697f47193960ec. --- gcc/config/xtensa/xtensa.cc | 2 ++ gcc/config/xtensa/xtensa.md | 20 +++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index

Re: [PATCH 1/2] xtensa: Fix non-fatal regression introduced by b2ef02e8cbbaf95fee98be255f697f47193960ec

2023-02-23 Thread Max Filippov via Gcc-patches
On Wed, Feb 22, 2023 at 7:42 PM Takayuki 'January June' Suwa wrote: > > In commit b2ef02e8cbbaf95fee98be255f697f47193960ec, the sibling call > insn included (use (reg:SI A0_REG)) to fix the problem, which added > a USE chain unconditionally to the data flow of register A0 during > the sibling

Re: [PATCH 2/2] xtensa: Fix missing mode warnings in machine description

2023-02-23 Thread Max Filippov via Gcc-patches
On Wed, Feb 22, 2023 at 7:42 PM Takayuki 'January June' Suwa wrote: > > gcc/ChangeLog: > > * config/xtensa/xtensa.md > (zero_cost_loop_start, zero_cost_loop_end, loop_end): > Add missing "SI:" to PLUS RTXes. > --- > gcc/config/xtensa/xtensa.md | 12 ++-- > 1 file

[COMMITTED] gcc: xtensa: fix PR target/108876

2023-02-21 Thread Max Filippov via Gcc-patches
gcc/ PR target/108876 * config/xtensa/xtensa.cc (xtensa_expand_epilogue): Drop emit_use for A0_REG. * config/xtensa/xtensa.md (sibcall, sibcall_internal) (sibcall_value, sibcall_value_internal): Add 'use' expression for A0_REG. ---

Re: [PATCH] xtensa: Enforce return address saving when -Og is specified

2023-02-20 Thread Max Filippov via Gcc-patches
On Fri, Feb 17, 2023 at 8:54 PM Takayuki 'January June' Suwa wrote: > > Leaf function often omits saving its return address to the stack slot, > and this feature often makes debugging very confusing, especially for > stack dump analysis. > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc

Re: [PATCH v6] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-02-15 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Thu, Jan 26, 2023 at 7:17 PM Takayuki 'January June' Suwa wrote: > > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that

Re: [PATCH v4] xtensa: Eliminate unnecessary general-purpose reg-reg moves

2023-01-24 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, Jan 23, 2023 at 7:43 PM Takayuki 'January June' Suwa wrote: > > Register-register move instructions that can be easily seen as > unnecessary by the human eye may remain in the compiled result. > For example: > > /* example */ > double test(double a, double b) { > return

Re: [PATCH v5] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-01-24 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, Jan 23, 2023 at 7:43 PM Takayuki 'January June' Suwa wrote: > > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that

Re: [PATCH] xtensa: Revise 89afb2e86fcb29c559b2957fdcbea0d01740c49b

2023-01-24 Thread Max Filippov via Gcc-patches
On Thu, Jan 19, 2023 at 7:33 PM Takayuki 'January June' Suwa wrote: > > In the previously posted patch > "xtensa: Make complex hard register clobber elimination more robust and > accurate", > the check code for insns that refer to the [DS]Cmode hard register before > it is overwritten after it

Re: [PATCH v4] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-01-22 Thread Max Filippov via Gcc-patches
On Fri, Jan 20, 2023 at 8:39 PM Takayuki 'January June' Suwa wrote: > On 2023/01/21 0:14, Max Filippov wrote: > > After having this many attempts and getting to the issues that are > > really hard to detect I wonder if the target backend is the right place > > for this optimization? > > > I guess

Re: [PATCH v3] xtensa: Eliminate unnecessary general-purpose reg-reg moves

2023-01-20 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Wed, Jan 18, 2023 at 9:06 PM Takayuki 'January June' Suwa wrote: > > Register-register move instructions that can be easily seen as > unnecessary by the human eye may remain in the compiled result. > For example: > > /* example */ > double test(double a, double b) { > return

Re: [PATCH v4] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-01-20 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Wed, Jan 18, 2023 at 7:50 PM Takayuki 'January June' Suwa wrote: > > In the previous patch, if insn is JUMP_INSN or CALL_INSN, it bypasses the reg > check (possibly FAIL). > > = > In the case of the CALL0 ABI, values that must be retained before and > after function calls

Re: [PATCH] xtensa: Optimize inversion of the MSB

2023-01-18 Thread Max Filippov via Gcc-patches
On Tue, Jan 17, 2023 at 9:43 PM Takayuki 'January June' Suwa wrote: > > Such operation can be done either bitwise-XOR or addition with -2147483648, > but the latter is one byte less if TARGET_DENSITY. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (xorsi3_internal): > Rename

Re: [PATCH v2] xtensa: Eliminate unnecessary general-purpose reg-reg moves

2023-01-18 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Tue, Jan 17, 2023 at 9:25 PM Takayuki 'January June' Suwa wrote: > > Register-register move instructions that can be easily seen as > unnecessary by the human eye may remain in the compiled result. > For example: > > /* example */ > double test(double a, double b) { > return

Re: [PATCH v3] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-01-18 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Tue, Jan 17, 2023 at 8:23 PM Takayuki 'January June' Suwa wrote: > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that >

Re: [PATCH v2] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-01-17 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, Jan 16, 2023 at 8:12 PM Takayuki 'January June' Suwa wrote: > > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that

Re: [PATCH] xtensa: Eliminate unnecessary general-purpose reg-reg moves

2023-01-17 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Mon, Jan 16, 2023 at 8:54 PM Takayuki 'January June' Suwa wrote: > > Register-register move instructions that can be easily seen as > unnecessary by the human eye may remain in the compiled result. > For example: > > /* example */ > double test(double a, double b) { > return

Re: [PATCH] xtensa: Eliminate the use of callee-saved register that saves and restores only once

2023-01-16 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Sun, Jan 15, 2023 at 6:53 PM Takayuki 'January June' Suwa wrote: > > In the case of the CALL0 ABI, values that must be retained before and > after function calls are placed in the callee-saved registers (A12 > through A15) and referenced later. However, it is often the case that

Re: [PATCH] xtensa: Remove old broken tweak for leaf function

2023-01-14 Thread Max Filippov via Gcc-patches
On Fri, Jan 13, 2023 at 9:03 PM Takayuki 'January June' Suwa wrote: > > In the before-IRA era, ORDER_REGS_FOR_LOCAL_ALLOC was called for each > function in Xtensa, and there was register allocation table reordering > for leaf functions to compensate for the poor performance of local-alloc. > >

Re: [PATCH 2/2] xtensa: Optimize ctzsi2 and ffssi2 a bit

2023-01-12 Thread Max Filippov via Gcc-patches
On Wed, Jan 11, 2023 at 8:26 PM Takayuki 'January June' Suwa wrote: > > This patch saves one byte when the Code Density Option is enabled, > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (ctzsi2, ffssi2): > Rearrange the emitting codes. > --- > gcc/config/xtensa/xtensa.md | 8

Re: [PATCH 1/2] xtensa: Tune "*btrue" insn pattern

2023-01-12 Thread Max Filippov via Gcc-patches
On Wed, Jan 11, 2023 at 8:26 PM Takayuki 'January June' Suwa wrote: > > This branch instruction has short encoding if EQ/NE comparison against > immediate zero when the Code Density Option is enabled, but its "length" > attribute was only for normal encoding. This patch fixes it. > > This patch

Re: [PATCH] xtensa: Make instruction cost estimation for size more accurate

2023-01-10 Thread Max Filippov via Gcc-patches
On Mon, Jan 9, 2023 at 7:34 PM Takayuki 'January June' Suwa wrote: > > Until now, we applied COSTS_N_INSNS() (multiplying by 4) after dividing > the instruction length by 3, so we couldn't express the difference less > than modulo 3 in insn cost for size (e.g. 11 Bytes and 12 bytes cost the >

Re: [PATCH v2] xtensa: Optimize bitwise splicing operation

2023-01-08 Thread Max Filippov via Gcc-patches
On Sat, Jan 7, 2023 at 9:04 PM Takayuki 'January June' Suwa wrote: > > This patch optimizes the operation of cutting and splicing two register > values at a specified bit position, in other words, combining (bitwise > ORing) bits 0 through (C-1) of the register with bits C through 31 > of the

Re: [PATCH] xtensa: Optimize bitwise splicing operation

2023-01-07 Thread Max Filippov via Gcc-patches
On Fri, Jan 6, 2023 at 6:55 PM Takayuki 'January June' Suwa wrote: > > This patch optimizes the operation of cutting and splicing two register > values at a specified bit position, in other words, combining (bitwise > ORing) bits 0 through (C-1) of the register with bits C through 31 > of the

Re: [PATCH v2] xtensa: Optimize stack frame adjustment more

2023-01-07 Thread Max Filippov via Gcc-patches
On Fri, Jan 6, 2023 at 6:55 PM Takayuki 'January June' Suwa wrote: > > This patch introduces a convenient helper function for integer immediate > addition with scratch register as needed, that splits and emits either > up to two ADDI/ADDMI machine instructions or an addition by register >

Re: [PATCH] xtensa: Optimize stack frame adjustment more

2023-01-06 Thread Max Filippov via Gcc-patches
On Thu, Jan 5, 2023 at 10:57 PM Takayuki 'January June' Suwa wrote: > By using the helper function, it makes stack frame adjustment logic > simplified and instruction count less in some cases. I've built a couple linux configurations with and without this change and I observe consistent code

Re: [PATCH] xtensa: Optimize stack frame adjustment more

2023-01-05 Thread Max Filippov via Gcc-patches
On Thu, Jan 5, 2023 at 7:35 PM Takayuki 'January June' Suwa wrote: > On second thought, it cannot be a good idea to split addition/subtraction to > the stack pointer. > > > -4aaf: b0a192 movia9, 0x1b0 > > -4ab2: 1f9aadd.n a1, a15, a9 > > > +4aaf:

Re: [PATCH] xtensa: Optimize stack frame adjustment more

2023-01-05 Thread Max Filippov via Gcc-patches
Hi Suwa-san, On Thu, Jan 5, 2023 at 3:57 AM Takayuki 'January June' Suwa wrote: > > This patch introduces a convenient helper function for integer immediate > addition with scratch register as needed, that splits and emits either > up to two ADDI/ADDMI machine instructions or an addition by

[COMMITTED] gcc: xtensa: use GP_RETURN_* instead of magic constant

2022-12-29 Thread Max Filippov via Gcc-patches
gcc/ * config/xtensa/xtensa.cc (xtensa_return_in_memory): Use GP_RETURN_* instead of magic constant. --- gcc/config/xtensa/xtensa.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index

Re: [PATCH] xtensa: Check DF availability before use

2022-12-29 Thread Max Filippov via Gcc-patches
On Thu, Dec 29, 2022 at 4:33 AM Takayuki 'January June' Suwa wrote: > > Parhaps no problem, but for safety. > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (xtensa_expand_prologue): Fix to check > DF availability before use of DF_* macros. > --- > gcc/config/xtensa/xtensa.cc | 2

[COMMITTED 1/4] xtensa: Tabify, and trim trailing spaces

2022-12-27 Thread Max Filippov via Gcc-patches
From: Takayuki 'January June' Suwa Cosmetic and no functional changes. gcc/ChangeLog: * config/xtensa/elf.h: Tabify, and trim trailing spaces. * config/xtensa/linux.h: Likewise. * config/xtensa/uclinux.h: Likewise. * config/xtensa/xtensa-dynconfig.c: Likewise.

[COMMITTED] gcc: xtensa: use define_c_enums instead of define_constants

2022-12-27 Thread Max Filippov via Gcc-patches
This improves RTL dumps readability. No functional changes. gcc/ * config/xtensa/xtensa.md (unspec): Extract UNSPEC_* constants into this enum. (unspecv): Extract UNSPECV_* constants into this enum. --- gcc/config/xtensa/xtensa.md | 46

[COMMITTED 2/4] xtensa: Clean up xtensa_expand_prologue

2022-12-27 Thread Max Filippov via Gcc-patches
From: Takayuki 'January June' Suwa gcc/ChangeLog: * config/xtensa/xtensa.cc (xtensa_expand_prologue): Modify to exit the inspection loops as soon as the necessity of stack pointer is found. --- gcc/config/xtensa/xtensa.cc | 10 -- 1 file changed, 8

[COMMITTED 3/4] xtensa: Change GP_RETURN{, _REG_COUNT} to GP_RETURN_{FIRST, LAST}

2022-12-27 Thread Max Filippov via Gcc-patches
From: Takayuki 'January June' Suwa gcc/ChangeLog: * config/xtensa/xtensa.h (GP_RETURN, GP_RETURN_REG_COUNT): Change to GP_RETURN_FIRST and GP_RETURN_LAST, respectively. * config/xtensa/xtensa.cc (xtensa_function_value, xtensa_libcall_value,

[COMMITTED 4/4] xtensa: Generate density instructions in set_frame_ptr

2022-12-27 Thread Max Filippov via Gcc-patches
From: Takayuki 'January June' Suwa gcc/ChangeLog: * config/xtensa/xtensa.md (set_frame_ptr): Fix to reflect TARGET_DENSITY. --- gcc/config/xtensa/xtensa.md | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/xtensa/xtensa.md

Re: [PATCH] xtensa: Apply a few minor fixes

2022-12-27 Thread Max Filippov via Gcc-patches
On Mon, Dec 26, 2022 at 10:30 PM Takayuki 'January June' Suwa wrote: > > Almost cosmetic and no functional changes. > > gcc/ChangeLog: > > * config/xtensa/*: Tabify, and trim trailing spaces. > * config/xtensa/xtensa.h (GP_RETURN, GP_RETURN_REG_COUNT): > Change to

[COMMITTED] libgcc: xtensa: remove stray symbols from X*HAL macro definitions

2022-12-08 Thread Max Filippov via Gcc-patches
libgcc/ * config/xtensa/xtensa-config-builtin.h (XCHAL_NUM_AREGS) (XCHAL_ICACHE_SIZE, XCHAL_DCACHE_SIZE, XCHAL_ICACHE_LINESIZE) (XCHAL_DCACHE_LINESIZE, XCHAL_MMU_MIN_PTE_PAGE_SIZE) (XSHAL_ABI): Remove stray symbols from macro definitions. ---

Re: [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration

2022-12-07 Thread Max Filippov via Gcc-patches
On Mon, Nov 28, 2022 at 4:46 PM Max Filippov wrote: > > Hello, > > this series addresses the long standing issue with xtensa configuration > support by adding a way to configure toolchain for a specific xtensa > core at runtime using the xtensa-dynconfig [1] library as a plugin. > On a platform

[PATCH v2 1/2] gcc: xtensa: allow dynamic configuration

2022-11-28 Thread Max Filippov via Gcc-patches
Import include/xtensa-dynconfig.h that defines XCHAL_* macros as fields of a structure returned from the xtensa_get_config_v function call. Define that structure and fill it with default parameter values specified in the include/xtensa-config.h. Define reusable function xtensa_load_config that

[PATCH v2 2/2] libgcc: xtensa: use built-in configuration

2022-11-28 Thread Max Filippov via Gcc-patches
Now that gcc provides __XCHAL_* definitions use them instead of XCHAL_* definitions from the include/xtensa-config.h. That makes libgcc dynamically configurable for the target xtensa core. libgcc/ * config/xtensa/crti.S (xtensa-config.h): Replace #inlcude with

[PATCH v2 0/2] gcc: xtensa: allow dynamic configuration

2022-11-28 Thread Max Filippov via Gcc-patches
Hello, this series addresses the long standing issue with xtensa configuration support by adding a way to configure toolchain for a specific xtensa core at runtime using the xtensa-dynconfig [1] library as a plugin. On a platform with shared library support single toolchain binary becomes capable

Re: [PATCH] gcc: m68k: fix PR target/107645

2022-11-16 Thread Max Filippov via Gcc-patches
On Tue, Nov 15, 2022 at 7:33 PM Jeff Law wrote: > Thanks for clarifying. ISTM that operand predicate is quite poorly named. > > OK for the trunk. Thanks. Applied to master. -- Max

Re: [PATCH] gcc: m68k: fix PR target/107645

2022-11-12 Thread Max Filippov via Gcc-patches
On Sat, Nov 12, 2022 at 11:42 AM Jeff Law wrote: > ISTM that we'd need to strip the unspec and process its argument > instead. I tried that first, the result was more ICEs because that pattern wasn't recognized at later stages. Then I read the change to the comment over the symbolic_operand

[PATCH] gcc: m68k: fix PR target/107645

2022-11-11 Thread Max Filippov via Gcc-patches
gcc/ PR target/107645 * config/m68k/predicates.md (symbolic_operand): Return false when UNSPEC is under the CONST node. --- Regtested with --enable-checking=all for target=m68k-linux-uclibc, no new regressions compared to the compiler built without checking. Ok for master?

Re: [RFA] gcc: fix PR rtl-optimization/107482

2022-11-08 Thread Max Filippov via Gcc-patches
On Mon, Nov 7, 2022 at 12:52 PM Vladimir Makarov wrote: > even better patch: > > diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc > index 4a1a325e8e3..ffe73b61c45 100644 > --- a/gcc/ira-color.cc > +++ b/gcc/ira-color.cc > @@ -2209,8 +2209,8 @@ assign_hard_reg (ira_allocno_t a, bool retry_p) >

[COMMITTED] gcc: fix PR rtl-optimization/107482

2022-11-08 Thread Max Filippov via Gcc-patches
gcc/ PR rtl-optimization/107482 * ira-color.cc (assign_hard_reg): Only call update_costs_from_copies when retry_p is false. --- gcc/ira-color.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc index

[RFA] gcc: fix PR rtl-optimization/107482

2022-11-07 Thread Max Filippov via Gcc-patches
gcc/ * ira-color.cc (update_costs_from_allocno): Check that allocno is in the consideration_allocno_bitmap before dereferencing ALLOCNO_COLOR_DATA (allocno). --- This fixes the invalid memory access, but I'm not sure if that's sufficient and there's no remaining higher

Re: [PATCH] xtensa: Fix out-of-bounds array access

2022-10-26 Thread Max Filippov via Gcc-patches
On Tue, Oct 25, 2022 at 11:27 PM Takayuki 'January June' Suwa wrote: > > On 2022/10/26 5:09, Jan-Benedict Glaw wrote: > > I didn't yet actually check the warning, it may be bogus. > > This "problem" can occur in the following two places calling > xtensa_split_DI_reg_imm(): > > - (define_expand

  1   2   >