public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect
@ 2015-04-22 16:18 Kyrill Tkachov
  2015-04-30 12:00 ` Kyrill Tkachov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 16:18 UTC (permalink / raw)
  To: GCC Patches; +Cc: Ramana Radhakrishnan, Richard Earnshaw

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

Hi all,

This hunk that slightly reduces the cost of immediate moves doesn't actually have any effect.
In the whole of SPEC2006 it didn't make a difference. In any case, I'd like to move to a point
where we use COSTS_N_INSNS units for our costs and not increment decrement them by one.

This patch removes that bit of logic and makes it slightly cleaner to look at. As far as I know
its logic has never been confirmed in practice.

Bootstrapped and tested on arm.

Ok for trunk?

Thanks,
Kyrill

2015-04-22  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * config/arm/arm.c (arm_new_rtx_costs): Do not lower cost
     immediate moves.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: arm-costs-reg-core-lower.patch --]
[-- Type: text/x-patch; name=arm-costs-reg-core-lower.patch, Size: 1001 bytes --]

commit e225669ff70f09520007b7898b170fb8fa75281f
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Wed Apr 8 10:18:23 2015 +0100

    [ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 0ef05c9..03988ac 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -9725,11 +9725,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 	     and we would otherwise be unable to work out the true cost.  */
 	  *cost = rtx_cost (SET_DEST (x), SET, 0, speed_p);
 	  outer_code = SET;
-	  /* Slightly lower the cost of setting a core reg to a constant.
-	     This helps break up chains and allows for better scheduling.  */
-	  if (REG_P (SET_DEST (x))
-	      && REGNO (SET_DEST (x)) <= LR_REGNUM)
-	    *cost -= 1;
+
 	  x = SET_SRC (x);
 	  /* Immediate moves with an immediate in the range [0, 255] can be
 	     encoded in 16 bits in Thumb mode.  */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect
  2015-04-22 16:18 [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect Kyrill Tkachov
@ 2015-04-30 12:00 ` Kyrill Tkachov
  2015-04-30 15:25 ` Marcus Shawcroft
  2015-05-06  7:15 ` Richard Sandiford
  2 siblings, 0 replies; 6+ messages in thread
From: Kyrill Tkachov @ 2015-04-30 12:00 UTC (permalink / raw)
  To: GCC Patches; +Cc: Ramana Radhakrishnan, Richard Earnshaw

Ping.
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01330.html

Thanks,
Kyrill

On 22/04/15 17:18, Kyrill Tkachov wrote:
> Hi all,
>
> This hunk that slightly reduces the cost of immediate moves doesn't actually have any effect.
> In the whole of SPEC2006 it didn't make a difference. In any case, I'd like to move to a point
> where we use COSTS_N_INSNS units for our costs and not increment decrement them by one.
>
> This patch removes that bit of logic and makes it slightly cleaner to look at. As far as I know
> its logic has never been confirmed in practice.
>
> Bootstrapped and tested on arm.
>
> Ok for trunk?
>
> Thanks,
> Kyrill
>
> 2015-04-22  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>       * config/arm/arm.c (arm_new_rtx_costs): Do not lower cost
>       immediate moves.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect
  2015-04-22 16:18 [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect Kyrill Tkachov
  2015-04-30 12:00 ` Kyrill Tkachov
@ 2015-04-30 15:25 ` Marcus Shawcroft
  2015-04-30 15:34   ` Marcus Shawcroft
  2015-05-06  7:15 ` Richard Sandiford
  2 siblings, 1 reply; 6+ messages in thread
From: Marcus Shawcroft @ 2015-04-30 15:25 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw

On 22 April 2015 at 17:18, Kyrill Tkachov <kyrylo.tkachov@arm.com> wrote:

> 2015-04-22  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>     * config/arm/arm.c (arm_new_rtx_costs): Do not lower cost
>     immediate moves.

OK
/Marcus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect
  2015-04-30 15:25 ` Marcus Shawcroft
@ 2015-04-30 15:34   ` Marcus Shawcroft
  0 siblings, 0 replies; 6+ messages in thread
From: Marcus Shawcroft @ 2015-04-30 15:34 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw

On 30 April 2015 at 16:22, Marcus Shawcroft <marcus.shawcroft@gmail.com> wrote:
> On 22 April 2015 at 17:18, Kyrill Tkachov <kyrylo.tkachov@arm.com> wrote:
>
>> 2015-04-22  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>>
>>     * config/arm/arm.c (arm_new_rtx_costs): Do not lower cost
>>     immediate moves.
>
> OK
> /Marcus

Ignore that, I'm not allowed to make that call. Wait for Ramana.
/Marcus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect
  2015-04-22 16:18 [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect Kyrill Tkachov
  2015-04-30 12:00 ` Kyrill Tkachov
  2015-04-30 15:25 ` Marcus Shawcroft
@ 2015-05-06  7:15 ` Richard Sandiford
  2015-05-06  8:13   ` Kyrill Tkachov
  2 siblings, 1 reply; 6+ messages in thread
From: Richard Sandiford @ 2015-05-06  7:15 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw

Kyrill Tkachov <kyrylo.tkachov@arm.com> writes:
> Hi all,
>
> This hunk that slightly reduces the cost of immediate moves doesn't
> actually have any effect.  In the whole of SPEC2006 it didn't make a
> difference. In any case, I'd like to move to a point where we use
> COSTS_N_INSNS units for our costs and not increment decrement them by
> one.

I wonder whether that's always a good idea though?  COSTS_N_INSNS exists
to allow these kinds of fractional costs.  It sounds like they're
not useful in this particular case, but e.g. one case where they
can be useful is if you want to say when optimising for size that two
instructions are the same size but one is slightly more preferable for
speed reasons.  This might help prefer a 2-instruction shift/add
sequence over a load-immediate followed by a general multiplication;
both have the same size, but the shift/add is often faster.  Giving
multiplication a slightly higher cost than COSTS_N_INSNS (1) makes
that clear.

It's not perfect of course.  Add too many fractional costs together
and a carry will give you an extra full instruction at some fairly
arbitrary point.  Maybe size costs should be a (size, speed) pair.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect
  2015-05-06  7:15 ` Richard Sandiford
@ 2015-05-06  8:13   ` Kyrill Tkachov
  0 siblings, 0 replies; 6+ messages in thread
From: Kyrill Tkachov @ 2015-05-06  8:13 UTC (permalink / raw)
  To: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw, rdsandiford

Hi Richard,

On 06/05/15 08:15, Richard Sandiford wrote:
> Kyrill Tkachov <kyrylo.tkachov@arm.com> writes:
>> Hi all,
>>
>> This hunk that slightly reduces the cost of immediate moves doesn't
>> actually have any effect.  In the whole of SPEC2006 it didn't make a
>> difference. In any case, I'd like to move to a point where we use
>> COSTS_N_INSNS units for our costs and not increment decrement them by
>> one.
> I wonder whether that's always a good idea though?  COSTS_N_INSNS exists
> to allow these kinds of fractional costs.  It sounds like they're
> not useful in this particular case, but e.g. one case where they
> can be useful is if you want to say when optimising for size that two
> instructions are the same size but one is slightly more preferable for
> speed reasons.  This might help prefer a 2-instruction shift/add
> sequence over a load-immediate followed by a general multiplication;
> both have the same size, but the shift/add is often faster.  Giving
> multiplication a slightly higher cost than COSTS_N_INSNS (1) makes
> that clear.

Yeah, that's the mult synthesis code in expmed.c
I think the problem here with the costs infrastructure
is that the backend doesn't know for what purpose it's
assigning costs. If it's told to assign a cost to a PLUS
it has no way of knowing that the add is being considered
as part of a replacement for a mult-immediate or whether
to merge it with a shift during combine or as part of an
address calculation during ivpopts or whatever other place
in the midend that calls rtx costs.

>
> It's not perfect of course.  Add too many fractional costs together
> and a carry will give you an extra full instruction at some fairly
> arbitrary point.  Maybe size costs should be a (size, speed) pair.

Yeah, that's a concern as well.
In any case, I'm not going to remove such increments/decrements
of costs from the backend without analysing their impact on
code quality.

Thanks,
Kyrill

>
> Thanks,
> Richard
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-06  8:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-22 16:18 [PATCH][ARM] Do not lower cost of setting core reg to constant. It doesn't have any effect Kyrill Tkachov
2015-04-30 12:00 ` Kyrill Tkachov
2015-04-30 15:25 ` Marcus Shawcroft
2015-04-30 15:34   ` Marcus Shawcroft
2015-05-06  7:15 ` Richard Sandiford
2015-05-06  8:13   ` Kyrill Tkachov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).