[Bug target/104110] AArch64 unnecessary use of call-preserved register

2022-01-19 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104110

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #4 from Andrew Pinski  ---
Dup of bug 86892 really.

*** This bug has been marked as a duplicate of bug 86892 ***

[Bug target/104110] AArch64 unnecessary use of call-preserved register

2022-01-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104110

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2022-01-19
   Keywords|ra  |
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1

--- Comment #3 from Andrew Pinski  ---
Rs6000 has:
  /* On the RS/6000, if it is valid in the insn, it is free.  */
case CONST_INT:
  if (((outer_code == SET
|| outer_code == PLUS
|| outer_code == MINUS)
   && (satisfies_constraint_I (x)
   || satisfies_constraint_L (x)))


While aarch64 has:
  /* If an instruction can incorporate a constant within the
 instruction, the instruction's expression avoids calling
 rtx_cost() on the constant.  If rtx_cost() is called on a
 constant, then it is usually because the constant must be
 moved into a register by one or more instructions.

 The exception is constant 0, which can be expressed
 as XZR/WZR and is therefore free.  The exception to this is
 if we have (set (reg) (const0_rtx)) in which case we must cost
 the move.  However, we can catch that when we cost the SET, so
 we don't need to consider that here.  */
  if (x == const0_rtx)
*cost = 0;
  else
{
  /* To an approximation, building any other constant is
 proportionally expensive to the number of instructions
 required to build that constant.  This is true whether we
 are compiling for SPEED or otherwise.  */
  if (!is_a  (mode, &int_mode))
int_mode = word_mode;
  *cost = COSTS_N_INSNS (aarch64_internal_mov_immediate
 (NULL_RTX, x, false, int_mode));
}


I think rs6000 definition should be used instead otherwise we get the case
where (set (reg) (reg)) is the same cost as (set (reg) (const_int)) so GCC
decides it is better to do the (set (reg) (reg)) instead of staying with the
(set (reg) (const_int)).

[Bug target/104110] AArch64 unnecessary use of call-preserved register

2022-01-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104110

Andrew Pinski  changed:

   What|Removed |Added

 Target|aarch64 |aarch64*-*-* arm*-*-*

--- Comment #2 from Andrew Pinski  ---
Ok, this is interesting. On PowerPC and x86_64, rtl cse does not do the cse of
the constant but for aarch64 and arm it does ...
There has to be some cost issue.

[Bug target/104110] AArch64 unnecessary use of call-preserved register

2022-01-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104110

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||ra

--- Comment #1 from Andrew Pinski  ---
This is interesting. The register allocation should have rematerlized the
constant on the other side of the call.