Re: [PATCH] Remove TARGET_GEN_MEMSET_SCRATCH_RTX since it's not used anymore.
On Wed, Mar 22, 2023 at 3:19 AM Richard Biener wrote: > > On Wed, Mar 22, 2023 at 8:07 AM Uros Bizjak wrote: > > > > On Wed, Mar 22, 2023 at 3:59 AM liuhongt wrote: > > > > > > The target hook is only used by i386, and the current definition is > > > same as default gen_reg_rtx. So there's no need for this target hook. > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > > Ok for trunk(or GCC14)? > > > > > > gcc/ChangeLog: > > > > > > * builtins.cc (builtin_memset_read_str): Replace > > > targetm.gen_memset_scratch_rtx with gen_reg_rtx. > > > (builtin_memset_gen_str): Ditto. > > > * config/i386/i386-expand.cc > > > (ix86_convert_const_wide_int_to_broadcast): Replace > > > ix86_gen_scratch_sse_rtx with gen_reg_rtx. > > > (ix86_expand_vector_move): Ditto. > > > * config/i386/i386-protos.h (ix86_gen_scratch_sse_rtx): > > > Removed. > > > * config/i386/i386.cc (ix86_gen_scratch_sse_rtx): Removed. > > > (TARGET_GEN_MEMSET_SCRATCH_RTX): Removed. > > > * doc/tm.texi: Remove TARGET_GEN_MEMSET_SCRATCH_RTX. > > > * doc/tm.texi.in: Ditto. > > > * target.def: Ditto. > > > > Looks trivial enough for gcc13, so OK for x86 part. > > > > Needs also OK from a middle-end reviewer. > > Is/was the code ever exercised for non-x86? HJ, what was the reason to > abstract this? > > OK if HJ thinks it was really unnecessary abstraction unlikely to be > required by another target. OK with me. Thanks. > Richard. > > > Thanks, > > Uros. > > > > > --- > > > gcc/builtins.cc| 4 ++-- > > > gcc/config/i386/i386-expand.cc | 6 +++--- > > > gcc/config/i386/i386-protos.h | 2 -- > > > gcc/config/i386/i386.cc| 12 > > > gcc/doc/tm.texi| 7 --- > > > gcc/doc/tm.texi.in | 2 -- > > > gcc/target.def | 9 - > > > 7 files changed, 5 insertions(+), 37 deletions(-) > > > > > > diff --git a/gcc/builtins.cc b/gcc/builtins.cc > > > index 90246e214d6..8026e2001b7 100644 > > > --- a/gcc/builtins.cc > > > +++ b/gcc/builtins.cc > > > @@ -4212,7 +4212,7 @@ builtin_memset_read_str (void *data, void *prev, > > > return const_vec; > > > > > >/* Use the move expander with CONST_VECTOR. */ > > > - target = targetm.gen_memset_scratch_rtx (mode); > > > + target = gen_reg_rtx (mode); > > >emit_move_insn (target, const_vec); > > >return target; > > > } > > > @@ -4256,7 +4256,7 @@ builtin_memset_gen_str (void *data, void *prev, > > > the memset expander. */ > > >insn_code icode = optab_handler (vec_duplicate_optab, mode); > > > > > > - target = targetm.gen_memset_scratch_rtx (mode); > > > + target = gen_reg_rtx (mode); > > >class expand_operand ops[2]; > > >create_output_operand ([0], target, mode); > > >create_input_operand ([1], (rtx) data, QImode); > > > diff --git a/gcc/config/i386/i386-expand.cc > > > b/gcc/config/i386/i386-expand.cc > > > index c1300dc4e26..1e3ce4b7c3f 100644 > > > --- a/gcc/config/i386/i386-expand.cc > > > +++ b/gcc/config/i386/i386-expand.cc > > > @@ -338,7 +338,7 @@ ix86_convert_const_wide_int_to_broadcast > > > (machine_mode mode, rtx op) > > >machine_mode vector_mode; > > >if (!mode_for_vector (broadcast_mode, nunits).exists (_mode)) > > > gcc_unreachable (); > > > - rtx target = ix86_gen_scratch_sse_rtx (vector_mode); > > > + rtx target = gen_reg_rtx (vector_mode); > > >bool ok = ix86_expand_vector_init_duplicate (false, vector_mode, > > >target, > > >GEN_INT (val_broadcast)); > > > @@ -686,7 +686,7 @@ ix86_expand_vector_move (machine_mode mode, rtx > > > operands[]) > > >if (!register_operand (op0, mode) > > > && !register_operand (op1, mode)) > > > { > > > - rtx scratch = ix86_gen_scratch_sse_rtx (mode); > > > + rtx scratch = gen_reg_rtx (mode); > > > emit_move_insn (scratch, op1); > > > op1 = scratch; > > > } > > > @@ -728,7 +728,7 @@ ix86_expand_vector_move (machine_mode mode, rtx > > > operands[]) > > >&& !register_operand (op0, mode) > > >&& !register_operand (op1, mode)) > > > { > > > - rtx tmp = ix86_gen_scratch_sse_rtx (GET_MODE (op0)); > > > + rtx tmp = gen_reg_rtx (GET_MODE (op0)); > > >emit_move_insn (tmp, op1); > > >emit_move_insn (op0, tmp); > > >return; > > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > > > index bfb2198265a..71ae95ffef7 100644 > > > --- a/gcc/config/i386/i386-protos.h > > > +++ b/gcc/config/i386/i386-protos.h > > > @@ -50,8 +50,6 @@ extern void ix86_reset_previous_fndecl (void); > > > > > > extern bool ix86_using_red_zone (void); > > > > > > -extern rtx ix86_gen_scratch_sse_rtx (machine_mode); > > >
Re: [PATCH] Remove TARGET_GEN_MEMSET_SCRATCH_RTX since it's not used anymore.
On Wed, Mar 22, 2023 at 11:18:33AM +0100, Richard Biener via Gcc-patches wrote: > Is/was the code ever exercised for non-x86? HJ, what was the reason to > abstract this? Initially the hook looked like rtx ix86_gen_scratch_sse_rtx (machine_mode mode) { if (TARGET_SSE) return gen_rtx_REG (mode, (TARGET_64BIT ? LAST_REX_SSE_REG : LAST_SSE_REG)); else return gen_reg_rtx (mode); } on x86, but then PR104704 changed it to the same definition as the default hook. So I think it is fine to remove it. > OK if HJ thinks it was really unnecessary abstraction unlikely to be > required by another target. Jakub
Re: [PATCH] Remove TARGET_GEN_MEMSET_SCRATCH_RTX since it's not used anymore.
On Wed, Mar 22, 2023 at 8:07 AM Uros Bizjak wrote: > > On Wed, Mar 22, 2023 at 3:59 AM liuhongt wrote: > > > > The target hook is only used by i386, and the current definition is > > same as default gen_reg_rtx. So there's no need for this target hook. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ok for trunk(or GCC14)? > > > > gcc/ChangeLog: > > > > * builtins.cc (builtin_memset_read_str): Replace > > targetm.gen_memset_scratch_rtx with gen_reg_rtx. > > (builtin_memset_gen_str): Ditto. > > * config/i386/i386-expand.cc > > (ix86_convert_const_wide_int_to_broadcast): Replace > > ix86_gen_scratch_sse_rtx with gen_reg_rtx. > > (ix86_expand_vector_move): Ditto. > > * config/i386/i386-protos.h (ix86_gen_scratch_sse_rtx): > > Removed. > > * config/i386/i386.cc (ix86_gen_scratch_sse_rtx): Removed. > > (TARGET_GEN_MEMSET_SCRATCH_RTX): Removed. > > * doc/tm.texi: Remove TARGET_GEN_MEMSET_SCRATCH_RTX. > > * doc/tm.texi.in: Ditto. > > * target.def: Ditto. > > Looks trivial enough for gcc13, so OK for x86 part. > > Needs also OK from a middle-end reviewer. Is/was the code ever exercised for non-x86? HJ, what was the reason to abstract this? OK if HJ thinks it was really unnecessary abstraction unlikely to be required by another target. Richard. > Thanks, > Uros. > > > --- > > gcc/builtins.cc| 4 ++-- > > gcc/config/i386/i386-expand.cc | 6 +++--- > > gcc/config/i386/i386-protos.h | 2 -- > > gcc/config/i386/i386.cc| 12 > > gcc/doc/tm.texi| 7 --- > > gcc/doc/tm.texi.in | 2 -- > > gcc/target.def | 9 - > > 7 files changed, 5 insertions(+), 37 deletions(-) > > > > diff --git a/gcc/builtins.cc b/gcc/builtins.cc > > index 90246e214d6..8026e2001b7 100644 > > --- a/gcc/builtins.cc > > +++ b/gcc/builtins.cc > > @@ -4212,7 +4212,7 @@ builtin_memset_read_str (void *data, void *prev, > > return const_vec; > > > >/* Use the move expander with CONST_VECTOR. */ > > - target = targetm.gen_memset_scratch_rtx (mode); > > + target = gen_reg_rtx (mode); > >emit_move_insn (target, const_vec); > >return target; > > } > > @@ -4256,7 +4256,7 @@ builtin_memset_gen_str (void *data, void *prev, > > the memset expander. */ > >insn_code icode = optab_handler (vec_duplicate_optab, mode); > > > > - target = targetm.gen_memset_scratch_rtx (mode); > > + target = gen_reg_rtx (mode); > >class expand_operand ops[2]; > >create_output_operand ([0], target, mode); > >create_input_operand ([1], (rtx) data, QImode); > > diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc > > index c1300dc4e26..1e3ce4b7c3f 100644 > > --- a/gcc/config/i386/i386-expand.cc > > +++ b/gcc/config/i386/i386-expand.cc > > @@ -338,7 +338,7 @@ ix86_convert_const_wide_int_to_broadcast (machine_mode > > mode, rtx op) > >machine_mode vector_mode; > >if (!mode_for_vector (broadcast_mode, nunits).exists (_mode)) > > gcc_unreachable (); > > - rtx target = ix86_gen_scratch_sse_rtx (vector_mode); > > + rtx target = gen_reg_rtx (vector_mode); > >bool ok = ix86_expand_vector_init_duplicate (false, vector_mode, > >target, > >GEN_INT (val_broadcast)); > > @@ -686,7 +686,7 @@ ix86_expand_vector_move (machine_mode mode, rtx > > operands[]) > >if (!register_operand (op0, mode) > > && !register_operand (op1, mode)) > > { > > - rtx scratch = ix86_gen_scratch_sse_rtx (mode); > > + rtx scratch = gen_reg_rtx (mode); > > emit_move_insn (scratch, op1); > > op1 = scratch; > > } > > @@ -728,7 +728,7 @@ ix86_expand_vector_move (machine_mode mode, rtx > > operands[]) > >&& !register_operand (op0, mode) > >&& !register_operand (op1, mode)) > > { > > - rtx tmp = ix86_gen_scratch_sse_rtx (GET_MODE (op0)); > > + rtx tmp = gen_reg_rtx (GET_MODE (op0)); > >emit_move_insn (tmp, op1); > >emit_move_insn (op0, tmp); > >return; > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > > index bfb2198265a..71ae95ffef7 100644 > > --- a/gcc/config/i386/i386-protos.h > > +++ b/gcc/config/i386/i386-protos.h > > @@ -50,8 +50,6 @@ extern void ix86_reset_previous_fndecl (void); > > > > extern bool ix86_using_red_zone (void); > > > > -extern rtx ix86_gen_scratch_sse_rtx (machine_mode); > > - > > extern unsigned int ix86_regmode_natural_size (machine_mode); > > extern bool ix86_check_builtin_isa_match (unsigned int fcode); > > #ifdef RTX_CODE > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > > index 5d0e4739a84..6a8734c2346 100644 > > --- a/gcc/config/i386/i386.cc > > +++
Re: [PATCH] Remove TARGET_GEN_MEMSET_SCRATCH_RTX since it's not used anymore.
On Wed, Mar 22, 2023 at 3:59 AM liuhongt wrote: > > The target hook is only used by i386, and the current definition is > same as default gen_reg_rtx. So there's no need for this target hook. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk(or GCC14)? > > gcc/ChangeLog: > > * builtins.cc (builtin_memset_read_str): Replace > targetm.gen_memset_scratch_rtx with gen_reg_rtx. > (builtin_memset_gen_str): Ditto. > * config/i386/i386-expand.cc > (ix86_convert_const_wide_int_to_broadcast): Replace > ix86_gen_scratch_sse_rtx with gen_reg_rtx. > (ix86_expand_vector_move): Ditto. > * config/i386/i386-protos.h (ix86_gen_scratch_sse_rtx): > Removed. > * config/i386/i386.cc (ix86_gen_scratch_sse_rtx): Removed. > (TARGET_GEN_MEMSET_SCRATCH_RTX): Removed. > * doc/tm.texi: Remove TARGET_GEN_MEMSET_SCRATCH_RTX. > * doc/tm.texi.in: Ditto. > * target.def: Ditto. Looks trivial enough for gcc13, so OK for x86 part. Needs also OK from a middle-end reviewer. Thanks, Uros. > --- > gcc/builtins.cc| 4 ++-- > gcc/config/i386/i386-expand.cc | 6 +++--- > gcc/config/i386/i386-protos.h | 2 -- > gcc/config/i386/i386.cc| 12 > gcc/doc/tm.texi| 7 --- > gcc/doc/tm.texi.in | 2 -- > gcc/target.def | 9 - > 7 files changed, 5 insertions(+), 37 deletions(-) > > diff --git a/gcc/builtins.cc b/gcc/builtins.cc > index 90246e214d6..8026e2001b7 100644 > --- a/gcc/builtins.cc > +++ b/gcc/builtins.cc > @@ -4212,7 +4212,7 @@ builtin_memset_read_str (void *data, void *prev, > return const_vec; > >/* Use the move expander with CONST_VECTOR. */ > - target = targetm.gen_memset_scratch_rtx (mode); > + target = gen_reg_rtx (mode); >emit_move_insn (target, const_vec); >return target; > } > @@ -4256,7 +4256,7 @@ builtin_memset_gen_str (void *data, void *prev, > the memset expander. */ >insn_code icode = optab_handler (vec_duplicate_optab, mode); > > - target = targetm.gen_memset_scratch_rtx (mode); > + target = gen_reg_rtx (mode); >class expand_operand ops[2]; >create_output_operand ([0], target, mode); >create_input_operand ([1], (rtx) data, QImode); > diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc > index c1300dc4e26..1e3ce4b7c3f 100644 > --- a/gcc/config/i386/i386-expand.cc > +++ b/gcc/config/i386/i386-expand.cc > @@ -338,7 +338,7 @@ ix86_convert_const_wide_int_to_broadcast (machine_mode > mode, rtx op) >machine_mode vector_mode; >if (!mode_for_vector (broadcast_mode, nunits).exists (_mode)) > gcc_unreachable (); > - rtx target = ix86_gen_scratch_sse_rtx (vector_mode); > + rtx target = gen_reg_rtx (vector_mode); >bool ok = ix86_expand_vector_init_duplicate (false, vector_mode, >target, >GEN_INT (val_broadcast)); > @@ -686,7 +686,7 @@ ix86_expand_vector_move (machine_mode mode, rtx > operands[]) >if (!register_operand (op0, mode) > && !register_operand (op1, mode)) > { > - rtx scratch = ix86_gen_scratch_sse_rtx (mode); > + rtx scratch = gen_reg_rtx (mode); > emit_move_insn (scratch, op1); > op1 = scratch; > } > @@ -728,7 +728,7 @@ ix86_expand_vector_move (machine_mode mode, rtx > operands[]) >&& !register_operand (op0, mode) >&& !register_operand (op1, mode)) > { > - rtx tmp = ix86_gen_scratch_sse_rtx (GET_MODE (op0)); > + rtx tmp = gen_reg_rtx (GET_MODE (op0)); >emit_move_insn (tmp, op1); >emit_move_insn (op0, tmp); >return; > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > index bfb2198265a..71ae95ffef7 100644 > --- a/gcc/config/i386/i386-protos.h > +++ b/gcc/config/i386/i386-protos.h > @@ -50,8 +50,6 @@ extern void ix86_reset_previous_fndecl (void); > > extern bool ix86_using_red_zone (void); > > -extern rtx ix86_gen_scratch_sse_rtx (machine_mode); > - > extern unsigned int ix86_regmode_natural_size (machine_mode); > extern bool ix86_check_builtin_isa_match (unsigned int fcode); > #ifdef RTX_CODE > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > index 5d0e4739a84..6a8734c2346 100644 > --- a/gcc/config/i386/i386.cc > +++ b/gcc/config/i386/i386.cc > @@ -24197,15 +24197,6 @@ ix86_optab_supported_p (int op, machine_mode mode1, > machine_mode, > } > } > > -/* Implement the TARGET_GEN_MEMSET_SCRATCH_RTX hook. Return a scratch > - register in MODE for vector load and store. */ > - > -rtx > -ix86_gen_scratch_sse_rtx (machine_mode mode) > -{ > - return gen_reg_rtx (mode); > -} > - > /* Address space support. > > This is not "far pointers" in the 16-bit sense, but an easy way > @@
[PATCH] Remove TARGET_GEN_MEMSET_SCRATCH_RTX since it's not used anymore.
The target hook is only used by i386, and the current definition is same as default gen_reg_rtx. So there's no need for this target hook. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk(or GCC14)? gcc/ChangeLog: * builtins.cc (builtin_memset_read_str): Replace targetm.gen_memset_scratch_rtx with gen_reg_rtx. (builtin_memset_gen_str): Ditto. * config/i386/i386-expand.cc (ix86_convert_const_wide_int_to_broadcast): Replace ix86_gen_scratch_sse_rtx with gen_reg_rtx. (ix86_expand_vector_move): Ditto. * config/i386/i386-protos.h (ix86_gen_scratch_sse_rtx): Removed. * config/i386/i386.cc (ix86_gen_scratch_sse_rtx): Removed. (TARGET_GEN_MEMSET_SCRATCH_RTX): Removed. * doc/tm.texi: Remove TARGET_GEN_MEMSET_SCRATCH_RTX. * doc/tm.texi.in: Ditto. * target.def: Ditto. --- gcc/builtins.cc| 4 ++-- gcc/config/i386/i386-expand.cc | 6 +++--- gcc/config/i386/i386-protos.h | 2 -- gcc/config/i386/i386.cc| 12 gcc/doc/tm.texi| 7 --- gcc/doc/tm.texi.in | 2 -- gcc/target.def | 9 - 7 files changed, 5 insertions(+), 37 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 90246e214d6..8026e2001b7 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -4212,7 +4212,7 @@ builtin_memset_read_str (void *data, void *prev, return const_vec; /* Use the move expander with CONST_VECTOR. */ - target = targetm.gen_memset_scratch_rtx (mode); + target = gen_reg_rtx (mode); emit_move_insn (target, const_vec); return target; } @@ -4256,7 +4256,7 @@ builtin_memset_gen_str (void *data, void *prev, the memset expander. */ insn_code icode = optab_handler (vec_duplicate_optab, mode); - target = targetm.gen_memset_scratch_rtx (mode); + target = gen_reg_rtx (mode); class expand_operand ops[2]; create_output_operand ([0], target, mode); create_input_operand ([1], (rtx) data, QImode); diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index c1300dc4e26..1e3ce4b7c3f 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -338,7 +338,7 @@ ix86_convert_const_wide_int_to_broadcast (machine_mode mode, rtx op) machine_mode vector_mode; if (!mode_for_vector (broadcast_mode, nunits).exists (_mode)) gcc_unreachable (); - rtx target = ix86_gen_scratch_sse_rtx (vector_mode); + rtx target = gen_reg_rtx (vector_mode); bool ok = ix86_expand_vector_init_duplicate (false, vector_mode, target, GEN_INT (val_broadcast)); @@ -686,7 +686,7 @@ ix86_expand_vector_move (machine_mode mode, rtx operands[]) if (!register_operand (op0, mode) && !register_operand (op1, mode)) { - rtx scratch = ix86_gen_scratch_sse_rtx (mode); + rtx scratch = gen_reg_rtx (mode); emit_move_insn (scratch, op1); op1 = scratch; } @@ -728,7 +728,7 @@ ix86_expand_vector_move (machine_mode mode, rtx operands[]) && !register_operand (op0, mode) && !register_operand (op1, mode)) { - rtx tmp = ix86_gen_scratch_sse_rtx (GET_MODE (op0)); + rtx tmp = gen_reg_rtx (GET_MODE (op0)); emit_move_insn (tmp, op1); emit_move_insn (op0, tmp); return; diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index bfb2198265a..71ae95ffef7 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -50,8 +50,6 @@ extern void ix86_reset_previous_fndecl (void); extern bool ix86_using_red_zone (void); -extern rtx ix86_gen_scratch_sse_rtx (machine_mode); - extern unsigned int ix86_regmode_natural_size (machine_mode); extern bool ix86_check_builtin_isa_match (unsigned int fcode); #ifdef RTX_CODE diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 5d0e4739a84..6a8734c2346 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -24197,15 +24197,6 @@ ix86_optab_supported_p (int op, machine_mode mode1, machine_mode, } } -/* Implement the TARGET_GEN_MEMSET_SCRATCH_RTX hook. Return a scratch - register in MODE for vector load and store. */ - -rtx -ix86_gen_scratch_sse_rtx (machine_mode mode) -{ - return gen_reg_rtx (mode); -} - /* Address space support. This is not "far pointers" in the 16-bit sense, but an easy way @@ -25253,9 +25244,6 @@ static bool ix86_libc_has_fast_function (int fcode ATTRIBUTE_UNUSED) #undef TARGET_LIBC_HAS_FAST_FUNCTION #define TARGET_LIBC_HAS_FAST_FUNCTION ix86_libc_has_fast_function -#undef TARGET_GEN_MEMSET_SCRATCH_RTX -#define TARGET_GEN_MEMSET_SCRATCH_RTX ix86_gen_scratch_sse_rtx - #if CHECKING_P #undef TARGET_RUN_TARGET_SELFTESTS #define TARGET_RUN_TARGET_SELFTESTS