Re: Make lra use per-alternative earlyclobber info

2019-07-30 Thread Vladimir Makarov



On 2019-07-30 5:58 a.m., Richard Sandiford wrote:

lra_insn_reg and lra_operand_data have both a bitmask of earlyclobber
alternatives and an overall boolean.  The danger is that we then test
the overall boolean when really we should be testing for a particular
alternative.  This patch gets rid of the boolean and tests the mask
against zero when we really do need to test "any alternative might
be earlyclobber".  (I think the only instance of that is the
LRA_UNKNOWN_ALT handling in lra-lives.c:reg_early_clobber_p.)

This is needed (and tested) by an upcoming SVE patch.

Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu.
OK to install?


Yes.  It looks good. Thank you for making the code more straightforward 
and accurate, Richard.





Make lra use per-alternative earlyclobber info

2019-07-30 Thread Richard Sandiford
lra_insn_reg and lra_operand_data have both a bitmask of earlyclobber
alternatives and an overall boolean.  The danger is that we then test
the overall boolean when really we should be testing for a particular
alternative.  This patch gets rid of the boolean and tests the mask
against zero when we really do need to test "any alternative might
be earlyclobber".  (I think the only instance of that is the
LRA_UNKNOWN_ALT handling in lra-lives.c:reg_early_clobber_p.)

This is needed (and tested) by an upcoming SVE patch.

Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu.
OK to install?

Thanks,
Richard


2019-07-30  Richard Sandiford  

gcc/
* lra-int.h (lra_operand_data): Remove early_clobber field.
(lra_insn_reg): Likewise.
* lra.c (debug_operand_data): Update accordingly.
(setup_operand_alternative): Likewise.
(new_insn_reg): Likewise.  Remove early_clobber parameter.
(collect_non_operand_hard_regs): Update call accordingly.
Don't assign to lra_insn_reg::early_clobber.
(add_regs_to_insn_regno_info): Remove early_clobber parameter
and update calls to new_insn_reg.
(lra_update_insn_regno_info): Update calls accordingly.
* lra-constraints.c (update_and_check_small_class_inputs): Take the
alternative number as a parameter and test whether the operand
is earlyclobbered in that particular alternative.
(process_alt_operands): Update call accordingly.  Use per-alternative
checks for earyclobber here too.
* lra-lives.c (reg_early_clobber_p): Check early_clobber_alts
against zero for IRA_UNKNOWN_ALT.

Index: gcc/lra-int.h
===
--- gcc/lra-int.h   2019-07-10 19:41:21.607936374 +0100
+++ gcc/lra-int.h   2019-07-30 10:51:22.999621161 +0100
@@ -142,10 +142,6 @@ struct lra_operand_data
   unsigned int strict_low : 1;
   /* True if the operand is an operator.  */
   unsigned int is_operator : 1;
-  /* True if there is an early clobber alternative for this operand.
- This field is set up every time when corresponding
- operand_alternative in lra_static_insn_data is set up.  */
-  unsigned int early_clobber : 1;
   /* True if the operand is an address.  */
   unsigned int is_address : 1;
 };
@@ -164,9 +160,6 @@ struct lra_insn_reg
   /* True if the reg is accessed through a subreg and the subreg is
  just a part of the register.  */
   unsigned int subreg_p : 1;
-  /* True if there is an early clobber alternative for this
- operand.  */
-  unsigned int early_clobber : 1;
   /* True if the reg is clobber highed by the operand.  */
   unsigned int clobber_high : 1;
   /* The corresponding regno of the register.  */
Index: gcc/lra.c
===
--- gcc/lra.c   2019-07-10 19:41:21.611936343 +0100
+++ gcc/lra.c   2019-07-30 10:51:22.999621161 +0100
@@ -536,16 +536,14 @@ object_allocator lra_insn_
 
 /* Create LRA insn related info about a reference to REGNO in INSN
with TYPE (in/out/inout), biggest reference mode MODE, flag that it
-   is reference through subreg (SUBREG_P), flag that is early
-   clobbered in the insn (EARLY_CLOBBER), and reference to the next
+   is reference through subreg (SUBREG_P), and reference to the next
insn reg info (NEXT).  If REGNO can be early clobbered,
alternatives in which it can be early clobbered are given by
EARLY_CLOBBER_ALTS.  CLOBBER_HIGH marks if reference is a clobber
high.  */
 static struct lra_insn_reg *
 new_insn_reg (rtx_insn *insn, int regno, enum op_type type,
- machine_mode mode,
- bool subreg_p, bool early_clobber,
+ machine_mode mode, bool subreg_p,
  alternative_mask early_clobber_alts,
  struct lra_insn_reg *next, bool clobber_high)
 {
@@ -556,7 +554,6 @@ new_insn_reg (rtx_insn *insn, int regno,
   && partial_subreg_p (lra_reg_info[regno].biggest_mode, mode))
 lra_reg_info[regno].biggest_mode = mode;
   ir->subreg_p = subreg_p;
-  ir->early_clobber = early_clobber;
   ir->early_clobber_alts = early_clobber_alts;
   ir->clobber_high = clobber_high;
   ir->regno = regno;
@@ -605,7 +602,7 @@ static struct lra_operand_data debug_ope
 0, /* early_clobber_alts */
 E_VOIDmode, /* We are not interesting in the operand mode.  */
 OP_IN,
-0, 0, 0, 0
+0, 0, 0
   };
 
 /* The following data are used as static insn data for all debug
@@ -801,7 +798,6 @@ setup_operand_alternative (lra_insn_reco
   for (i = 0; i < nop; i++)
 {
   static_data->operand[i].early_clobber_alts = 0;
-  static_data->operand[i].early_clobber = false;
   static_data->operand[i].is_address = false;
   if (static_data->operand[i].constraint[0] == '%')
{
@@ -817,7 +813,6 @@ setup_operand_alternative (lra_insn_reco
   for (j = 0; j < nalt; j++)
 for (i = 0; i < nop; i++, op_alt++)
   {
-