xtensa: Make full transition to LRA

Message ID 91ddbcb5-67e2-2c30-a81e-6b20e3c8e1a4@yahoo.co.jp
State New
Headers
Series xtensa: Make full transition to LRA |

Commit Message

Takayuki 'January June' Suwa May 8, 2023, 1:38 p.m. UTC
  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): Remove.
	(xtensa_emit_move_sequence): Remove "if (reload_in_progress)"
	clause as it can no longer be true.
	(xtensa_output_integer_literal_parts): Consider 16-bit wide
	constants.
	(xtensa_legitimate_constant_p): Add short-circuit path for
	integer load instructions.
	* config/xtensa/xtensa.md (movsf): Use can_create_pseudo_p()
	rather reload_in_progress and reload_completed.
	* config/xtensa/xtensa.opt (mlra): Remove.
---
 gcc/config/xtensa/constraints.md | 26 ++++++++------------------
 gcc/config/xtensa/xtensa.cc      | 26 +++++---------------------
 gcc/config/xtensa/xtensa.md      |  2 +-
 gcc/config/xtensa/xtensa.opt     |  4 ----
 4 files changed, 14 insertions(+), 44 deletions(-)
  

Comments

Richard Biener May 8, 2023, 1:43 p.m. UTC | #1
On Mon, May 8, 2023 at 3:39 PM Takayuki 'January June' Suwa via
Gcc-patches <gcc-patches@gcc.gnu.org> 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): Remove.
>         (xtensa_emit_move_sequence): Remove "if (reload_in_progress)"
>         clause as it can no longer be true.
>         (xtensa_output_integer_literal_parts): Consider 16-bit wide
>         constants.
>         (xtensa_legitimate_constant_p): Add short-circuit path for
>         integer load instructions.
>         * config/xtensa/xtensa.md (movsf): Use can_create_pseudo_p()
>         rather reload_in_progress and reload_completed.
>         * config/xtensa/xtensa.opt (mlra): Remove.
> ---
>  gcc/config/xtensa/constraints.md | 26 ++++++++------------------
>  gcc/config/xtensa/xtensa.cc      | 26 +++++---------------------
>  gcc/config/xtensa/xtensa.md      |  2 +-
>  gcc/config/xtensa/xtensa.opt     |  4 ----
>  4 files changed, 14 insertions(+), 44 deletions(-)
>
> diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md
> index 53e4d0d8dd1..9b31e162941 100644
> --- a/gcc/config/xtensa/constraints.md
> +++ b/gcc/config/xtensa/constraints.md
> @@ -123,29 +123,19 @@
>        (and (match_code "const_int")
>            (match_test "! xtensa_split1_finished_p ()"))))
>
> -;; Memory constraints.  Do not use define_memory_constraint here.  Doing so
> -;; causes reload to force some constants into the constant pool, but since
> -;; the Xtensa constant pool can only be accessed with L32R instructions, it
> -;; is always better to just copy a constant into a register.  Instead, use
> -;; regular constraints but add a check to allow pseudos during reload.
> +;; Memory constraints.
>
> -(define_constraint "R"
> +(define_memory_constraint "R"
>   "Memory that can be accessed with a 4-bit unsigned offset from a register."
> - (ior (and (match_code "mem")
> -          (match_test "smalloffset_mem_p (op)"))
> -      (and (match_code "reg")
> -          (match_test "reload_in_progress
> -                       && REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
> + (and (match_code "mem")
> +      (match_test "smalloffset_mem_p (op)")))
>
> -(define_constraint "T"
> +(define_memory_constraint "T"
>   "Memory in a literal pool (addressable with an L32R instruction)."
>   (and (match_code "mem")
>        (match_test "!TARGET_CONST16 && constantpool_mem_p (op)")))
>
> -(define_constraint "U"
> +(define_memory_constraint "U"
>   "Memory that is not in a literal pool."
> - (ior (and (match_code "mem")
> -          (match_test "! constantpool_mem_p (op)"))
> -      (and (match_code "reg")
> -          (match_test "reload_in_progress
> -                       && REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
> + (and (match_code "mem")
> +      (match_test "! constantpool_mem_p (op)")))
> diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
> index 9e5d314e143..f4434ec6e2c 100644
> --- a/gcc/config/xtensa/xtensa.cc
> +++ b/gcc/config/xtensa/xtensa.cc
> @@ -190,7 +190,6 @@ static void xtensa_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
>                                     HOST_WIDE_INT delta,
>                                     HOST_WIDE_INT vcall_offset,
>                                     tree function);
> -static bool xtensa_lra_p (void);
>
>  static rtx xtensa_delegitimize_address (rtx);
>
> @@ -286,9 +285,6 @@ static rtx xtensa_delegitimize_address (rtx);
>  #undef TARGET_CANNOT_FORCE_CONST_MEM
>  #define TARGET_CANNOT_FORCE_CONST_MEM xtensa_cannot_force_const_mem
>
> -#undef TARGET_LRA_P
> -#define TARGET_LRA_P xtensa_lra_p
> -
>  #undef TARGET_LEGITIMATE_ADDRESS_P
>  #define TARGET_LEGITIMATE_ADDRESS_P    xtensa_legitimate_address_p
>
> @@ -1266,14 +1262,6 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode)
>
>    operands[1] = xtensa_copy_incoming_a7 (operands[1]);
>
> -  /* During reload we don't want to emit (subreg:X (mem:Y)) since that
> -     instruction won't be recognized after reload, so we remove the
> -     subreg and adjust mem accordingly.  */
> -  if (reload_in_progress)
> -    {
> -      operands[0] = fixup_subreg_mem (operands[0]);
> -      operands[1] = fixup_subreg_mem (operands[1]);
> -    }
>    return 0;
>  }
>
> @@ -3196,7 +3184,7 @@ xtensa_output_integer_literal_parts (FILE *file, rtx x, int size)
>        fputs (", ", file);
>        xtensa_output_integer_literal_parts (file, second, size / 2);
>      }
> -  else if (size == 4)
> +  else if (size == 4 || size == 2)
>      {
>        output_addr_const (file, x);
>      }
> @@ -4876,6 +4864,10 @@ xtensa_trampoline_init (rtx m_tramp, tree fndecl, rtx chain)
>  static bool
>  xtensa_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
>  {
> +  if (CONST_INT_P (x))
> +    return TARGET_AUTO_LITPOOLS || TARGET_CONST16
> +          || xtensa_simm12b (INTVAL (x));
> +
>    return !xtensa_tls_referenced_p (x);
>  }
>
> @@ -5317,12 +5309,4 @@ xtensa_delegitimize_address (rtx op)
>    return op;
>  }
>
> -/* Implement TARGET_LRA_P.  */
> -
> -static bool
> -xtensa_lra_p (void)
> -{
> -  return TARGET_LRA;
> -}
> -
>  #include "gt-xtensa.h"
> diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
> index 3521fa33b47..195515d9427 100644
> --- a/gcc/config/xtensa/xtensa.md
> +++ b/gcc/config/xtensa/xtensa.md
> @@ -1268,7 +1268,7 @@
>    if ((!register_operand (operands[0], SFmode)
>         && !register_operand (operands[1], SFmode))
>        || (FP_REG_P (xt_true_regnum (operands[0]))
> -         && !(reload_in_progress | reload_completed)
> +         && can_create_pseudo_p ()
>           && (constantpool_mem_p (operands[1])
>               || CONSTANT_P (operands[1]))))
>      operands[1] = force_reg (SFmode, operands[1]);
> diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
> index f16b53bf409..8574c12198e 100644
> --- a/gcc/config/xtensa/xtensa.opt
> +++ b/gcc/config/xtensa/xtensa.opt
> @@ -37,10 +37,6 @@ mextra-l32r-costs=
>  Target RejectNegative Joined UInteger Var(xtensa_extra_l32r_costs) Init(0)
>  Set extra memory access cost for L32R instruction, in clock-cycle units.
>
> -mlra

If they were in any released compiler options should be kept
(doing nothing) for backward compatibility.  Use for example

mlra
Target WarnRemoved
Removed in GCC 14.  This switch has no effect.

or

mlra
Target Ignore
Does nothing.  Preserved for backward compatibility.

which doesn't inform the user (I think that's the better choice here).

> -Target Mask(LRA)
> -Use LRA instead of reload (transitional).
> -
>  mtarget-align
>  Target
>  Automatically align branch targets to reduce branch penalties.
> --
> 2.30.2
  
Max Filippov May 10, 2023, 9:10 a.m. UTC | #2
Hi Suwa-san,

On Mon, May 8, 2023 at 6:38 AM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> 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): Remove.
>         (xtensa_emit_move_sequence): Remove "if (reload_in_progress)"
>         clause as it can no longer be true.
>         (xtensa_output_integer_literal_parts): Consider 16-bit wide
>         constants.
>         (xtensa_legitimate_constant_p): Add short-circuit path for
>         integer load instructions.
>         * config/xtensa/xtensa.md (movsf): Use can_create_pseudo_p()
>         rather reload_in_progress and reload_completed.
>         * config/xtensa/xtensa.opt (mlra): Remove.
> ---
>  gcc/config/xtensa/constraints.md | 26 ++++++++------------------
>  gcc/config/xtensa/xtensa.cc      | 26 +++++---------------------
>  gcc/config/xtensa/xtensa.md      |  2 +-
>  gcc/config/xtensa/xtensa.opt     |  4 ----
>  4 files changed, 14 insertions(+), 44 deletions(-)

That's impressive.
This version introduces a few execution failures in the testsuite on
little endian targets and a bunch more (but not all, some execution
tests still pass) on big endian.
I'm traveling this week and likely won't be able to take a deep look
into it until 5/15.

New LE failures:

+FAIL: gcc.c-torture/execute/pr56866.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.dg/torture/pr45764.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.dg/torture/pr45764.c   -O3 -g  execution test

+FAIL: gfortran.dg/c-interop/section-2.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.dg/c-interop/section-2p.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.dg/c-interop/section-3.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.dg/c-interop/section-3p.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.dg/bind-c-contiguous-3.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.dg/bind-c-contiguous-3.f90   -O3 -g  execution test
+FAIL: gfortran.dg/check_bits_2.f90   -O1  output pattern test
+FAIL: gfortran.dg/coarray_ptr_comp_1.f08   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.dg/coarray_ptr_comp_1.f08   -O3 -g  execution test
+FAIL: gfortran.dg/loc_2.f90   -O2  execution test
+FAIL: gfortran.dg/loc_2.f90   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions  execution test
+FAIL: gfortran.dg/loc_2.f90   -O3 -g  execution test
+FAIL: gfortran.dg/loc_2.f90   -Os  execution test
+FAIL: gfortran.dg/sizeof_6.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gfortran.fortran-torture/execute/forall_7.f90 execution,  -O2
-fbounds-check

New BE failures:

+FAIL: gcc.c-torture/execute/builtins/memset-chk.c execution,  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions
+FAIL: gcc.c-torture/execute/builtins/memset-chk.c execution,  -O3 -g
+FAIL: gcc.c-torture/execute/20000412-3.c   -O2  execution test
+FAIL: gcc.c-torture/execute/20000412-3.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/20000412-3.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/20020201-1.c   -O2  execution test
+FAIL: gcc.c-torture/execute/20020201-1.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/20020201-1.c   -Os  execution test
+FAIL: gcc.c-torture/execute/20020201-1.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/20030224-2.c   -O0  execution test
+FAIL: gcc.c-torture/execute/20040629-1.c   -O0  execution test
+FAIL: gcc.c-torture/execute/20040629-1.c   -O1  execution test
+FAIL: gcc.c-torture/execute/20040705-1.c   -O0  execution test
+FAIL: gcc.c-torture/execute/20040705-1.c   -O1  execution test
+FAIL: gcc.c-torture/execute/20040705-2.c   -O0  execution test
+FAIL: gcc.c-torture/execute/20040705-2.c   -O1  execution test
+FAIL: gcc.c-torture/execute/930603-3.c   -O2  execution test
+FAIL: gcc.c-torture/execute/930603-3.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/930603-3.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/931004-10.c   -O2  execution test
+FAIL: gcc.c-torture/execute/931004-10.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.c-torture/execute/931004-10.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/931004-10.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/931004-10.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.c-torture/execute/931004-7.c   -O2  execution test
+FAIL: gcc.c-torture/execute/931004-7.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/931004-7.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/931004-8.c   -O2  execution test
+FAIL: gcc.c-torture/execute/931004-8.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.c-torture/execute/931004-8.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/931004-8.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/931004-8.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.c-torture/execute/931004-9.c   -O2  execution test
+FAIL: gcc.c-torture/execute/931004-9.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/931004-9.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/950322-1.c   -O2  execution test
+FAIL: gcc.c-torture/execute/950322-1.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/950322-1.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/bf-pack-1.c   -O0  execution test
+FAIL: gcc.c-torture/execute/bf-pack-1.c   -O1  execution test
+FAIL: gcc.c-torture/execute/bf-pack-1.c   -O2  execution test
+FAIL: gcc.c-torture/execute/bf-pack-1.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/bf-pack-1.c   -Os  execution test
+FAIL: gcc.c-torture/execute/bf-pack-1.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -O0  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -O1  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -O2  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.c-torture/execute/pr56866.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -Os  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/pr56866.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -O0  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -O1  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -O2  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.c-torture/execute/pr82210.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -Os  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/pr82210.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.c-torture/execute/strct-stdarg-1.c   -O2  execution test
+FAIL: gcc.c-torture/execute/strct-stdarg-1.c   -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  execution test
+FAIL: gcc.c-torture/execute/strct-stdarg-1.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/strct-stdarg-1.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/strct-stdarg-1.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.c-torture/execute/va-arg-22.c   -O2  execution test
+FAIL: gcc.c-torture/execute/va-arg-22.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.c-torture/execute/va-arg-22.c   -O3 -g  execution test
+FAIL: gcc.c-torture/execute/va-arg-22.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.c-torture/execute/va-arg-22.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: tmpdir-gcc.dg-struct-layout-1/t001
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t002
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t003
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t004
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t005
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t006
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t007
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t008
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t009
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t010
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t011
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t012
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t013
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t014
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t015
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t016
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t017
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t018
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t019
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t020
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t021
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t022
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t023
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t024
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t025
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t026
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t027
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: tmpdir-gcc.dg-struct-layout-1/t028
c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: gcc.dg/pr10392-1.c execution test
+FAIL: gcc.dg/strcmp-1.c execution test
+FAIL: gcc.dg/strlenopt-21.c execution test
+FAIL: gcc.dg/strlenopt-84.c execution test
+FAIL: gcc.dg/strncmp-1.c execution test
+FAIL: c-c++-common/torture/builtin-arith-overflow-16.c   -O0  execution test
+FAIL: c-c++-common/torture/builtin-arith-overflow-5.c   -O0  execution test
+FAIL: c-c++-common/torture/builtin-arith-overflow-p-16.c   -O0  execution test
+FAIL: c-c++-common/torture/builtin-arith-overflow-p-5.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -O1  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -O2  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -Os  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.dg/torture/fp-int-convert-double.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -O1  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -O2  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -Os  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -O1  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -O2  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -Os  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -O1  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -O2  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -Os  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float32x.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -O1  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -O2  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -Os  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.dg/torture/fp-int-convert-float64.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -O0  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -O1  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -O2  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -Os  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
+FAIL: gcc.dg/torture/fp-int-convert-long-double.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/pr100499-1.c   -O1  execution test
+FAIL: gcc.dg/torture/pr100499-1.c   -O2  execution test
+FAIL: gcc.dg/torture/pr100499-1.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/pr100499-1.c   -Os  execution test
+FAIL: gcc.dg/torture/pr100499-1.c   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
+FAIL: gcc.dg/torture/pr100499-1.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/pr45764.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.dg/torture/pr45764.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/pr61346.c   -O2  execution test
+FAIL: gcc.dg/torture/pr61346.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.dg/torture/pr61346.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/pr61346.c   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
+FAIL: gcc.dg/torture/pr61346.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/pr70542.c   -O0  execution test
+FAIL: gcc.dg/torture/pr70542.c   -O1  execution test
+FAIL: gcc.dg/torture/pr70542.c   -O2  execution test
+FAIL: gcc.dg/torture/pr70542.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
+FAIL: gcc.dg/torture/pr70542.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/pr70542.c   -Os  execution test
+FAIL: gcc.dg/torture/pr70542.c   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
+FAIL: gcc.dg/torture/pr70542.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.dg/torture/pr77436.c   -O0  execution test
+FAIL: gcc.dg/torture/pr97812.c   -O0  execution test
+FAIL: gcc.dg/torture/pr97812.c   -O1  execution test
+FAIL: gcc.dg/torture/pr97812.c   -O2  execution test
+FAIL: gcc.dg/torture/pr97812.c   -O3 -g  execution test
+FAIL: gcc.dg/torture/pr97812.c   -Os  execution test
+FAIL: gcc.dg/torture/pr97812.c   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
+FAIL: gcc.dg/torture/pr97812.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.dg/tree-ssa/pr84969.c execution test

and some more in the gfortran testsuite.
  
Max Filippov Jan. 24, 2024, 5:07 a.m. UTC | #3
Hi Suwa-san,

I've finally processed the new issues introduced by this change.

On Wed, May 10, 2023 at 2:10 AM Max Filippov <jcmvbkbc@gmail.com> wrote:
> On Mon, May 8, 2023 at 6:38 AM Takayuki 'January June' Suwa
> <jjsuwa_sys3175@yahoo.co.jp> 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): Remove.
> >         (xtensa_emit_move_sequence): Remove "if (reload_in_progress)"
> >         clause as it can no longer be true.
> >         (xtensa_output_integer_literal_parts): Consider 16-bit wide
> >         constants.
> >         (xtensa_legitimate_constant_p): Add short-circuit path for
> >         integer load instructions.
> >         * config/xtensa/xtensa.md (movsf): Use can_create_pseudo_p()
> >         rather reload_in_progress and reload_completed.
> >         * config/xtensa/xtensa.opt (mlra): Remove.
> > ---
> >  gcc/config/xtensa/constraints.md | 26 ++++++++------------------
> >  gcc/config/xtensa/xtensa.cc      | 26 +++++---------------------
> >  gcc/config/xtensa/xtensa.md      |  2 +-
> >  gcc/config/xtensa/xtensa.opt     |  4 ----
> >  4 files changed, 14 insertions(+), 44 deletions(-)
>
> That's impressive.
> This version introduces a few execution failures in the testsuite on
> little endian targets and a bunch more (but not all, some execution
> tests still pass) on big endian.
> I'm traveling this week and likely won't be able to take a deep look
> into it until 5/15.
>
> New LE failures:

All of the LE failures are related to zero-overhead loops. Dropping the
operand 2 from the doloop_end pattern fixes that (change 1).

> New BE failures:

All of the BE failures are related to loading HImode constants into
registers, which instead of

.literal .LCx value
...
l32r register, .LCx

now generates the following code:

.literal .LCx value
.literal .LCy .LCx
...
l32r register1, .LCy
l16ui register, register1, 0

I've fixed that by allowing HImode constants in the literal pool in the
'move_operand' predicate, making addresses of such constants
legitimate in the xtensa_legitimate_address_p and adding an
alternative with l32r opcode to the movhi_internal pattern (change 2).

With these additional changes there's no new regression failures
and the generated code looks mostly the same as with the reload.

--
Thanks.
-- Max
  

Patch

diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md
index 53e4d0d8dd1..9b31e162941 100644
--- a/gcc/config/xtensa/constraints.md
+++ b/gcc/config/xtensa/constraints.md
@@ -123,29 +123,19 @@ 
       (and (match_code "const_int")
 	   (match_test "! xtensa_split1_finished_p ()"))))
 
-;; Memory constraints.  Do not use define_memory_constraint here.  Doing so
-;; causes reload to force some constants into the constant pool, but since
-;; the Xtensa constant pool can only be accessed with L32R instructions, it
-;; is always better to just copy a constant into a register.  Instead, use
-;; regular constraints but add a check to allow pseudos during reload.
+;; Memory constraints.
 
-(define_constraint "R"
+(define_memory_constraint "R"
  "Memory that can be accessed with a 4-bit unsigned offset from a register."
- (ior (and (match_code "mem")
-	   (match_test "smalloffset_mem_p (op)"))
-      (and (match_code "reg")
-	   (match_test "reload_in_progress
-			&& REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
+ (and (match_code "mem")
+      (match_test "smalloffset_mem_p (op)")))
 
-(define_constraint "T"
+(define_memory_constraint "T"
  "Memory in a literal pool (addressable with an L32R instruction)."
  (and (match_code "mem")
       (match_test "!TARGET_CONST16 && constantpool_mem_p (op)")))
 
-(define_constraint "U"
+(define_memory_constraint "U"
  "Memory that is not in a literal pool."
- (ior (and (match_code "mem")
-	   (match_test "! constantpool_mem_p (op)"))
-      (and (match_code "reg")
-	   (match_test "reload_in_progress
-			&& REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
+ (and (match_code "mem")
+      (match_test "! constantpool_mem_p (op)")))
diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index 9e5d314e143..f4434ec6e2c 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -190,7 +190,6 @@  static void xtensa_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED,
 				    HOST_WIDE_INT delta,
 				    HOST_WIDE_INT vcall_offset,
 				    tree function);
-static bool xtensa_lra_p (void);
 
 static rtx xtensa_delegitimize_address (rtx);
 
@@ -286,9 +285,6 @@  static rtx xtensa_delegitimize_address (rtx);
 #undef TARGET_CANNOT_FORCE_CONST_MEM
 #define TARGET_CANNOT_FORCE_CONST_MEM xtensa_cannot_force_const_mem
 
-#undef TARGET_LRA_P
-#define TARGET_LRA_P xtensa_lra_p
-
 #undef TARGET_LEGITIMATE_ADDRESS_P
 #define TARGET_LEGITIMATE_ADDRESS_P	xtensa_legitimate_address_p
 
@@ -1266,14 +1262,6 @@  xtensa_emit_move_sequence (rtx *operands, machine_mode mode)
 
   operands[1] = xtensa_copy_incoming_a7 (operands[1]);
 
-  /* During reload we don't want to emit (subreg:X (mem:Y)) since that
-     instruction won't be recognized after reload, so we remove the
-     subreg and adjust mem accordingly.  */
-  if (reload_in_progress)
-    {
-      operands[0] = fixup_subreg_mem (operands[0]);
-      operands[1] = fixup_subreg_mem (operands[1]);
-    }
   return 0;
 }
 
@@ -3196,7 +3184,7 @@  xtensa_output_integer_literal_parts (FILE *file, rtx x, int size)
       fputs (", ", file);
       xtensa_output_integer_literal_parts (file, second, size / 2);
     }
-  else if (size == 4)
+  else if (size == 4 || size == 2)
     {
       output_addr_const (file, x);
     }
@@ -4876,6 +4864,10 @@  xtensa_trampoline_init (rtx m_tramp, tree fndecl, rtx chain)
 static bool
 xtensa_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
 {
+  if (CONST_INT_P (x))
+    return TARGET_AUTO_LITPOOLS || TARGET_CONST16
+	   || xtensa_simm12b (INTVAL (x));
+
   return !xtensa_tls_referenced_p (x);
 }
 
@@ -5317,12 +5309,4 @@  xtensa_delegitimize_address (rtx op)
   return op;
 }
 
-/* Implement TARGET_LRA_P.  */
-
-static bool
-xtensa_lra_p (void)
-{
-  return TARGET_LRA;
-}
-
 #include "gt-xtensa.h"
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 3521fa33b47..195515d9427 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -1268,7 +1268,7 @@ 
   if ((!register_operand (operands[0], SFmode)
        && !register_operand (operands[1], SFmode))
       || (FP_REG_P (xt_true_regnum (operands[0]))
-	  && !(reload_in_progress | reload_completed)
+	  && can_create_pseudo_p ()
 	  && (constantpool_mem_p (operands[1])
 	      || CONSTANT_P (operands[1]))))
     operands[1] = force_reg (SFmode, operands[1]);
diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
index f16b53bf409..8574c12198e 100644
--- a/gcc/config/xtensa/xtensa.opt
+++ b/gcc/config/xtensa/xtensa.opt
@@ -37,10 +37,6 @@  mextra-l32r-costs=
 Target RejectNegative Joined UInteger Var(xtensa_extra_l32r_costs) Init(0)
 Set extra memory access cost for L32R instruction, in clock-cycle units.
 
-mlra
-Target Mask(LRA)
-Use LRA instead of reload (transitional).
-
 mtarget-align
 Target
 Automatically align branch targets to reduce branch penalties.