public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tamar Christina <Tamar.Christina@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: nd <nd@arm.com>, Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>,
	"Ramana Radhakrishnan" <Ramana.Radhakrishnan@arm.com>,
	Richard Earnshaw	<Richard.Earnshaw@arm.com>,
	"nickc@redhat.com" <nickc@redhat.com>
Subject: Re: [PATCH][GCC][ARM] Adjust costs so udiv is preferred over sdiv when both are valid. [Patch (2/2)]
Date: Mon, 15 May 2017 08:33:00 -0000	[thread overview]
Message-ID: <VI1PR0801MB2031234BF60BF46E6CBE4FA6FFE10@VI1PR0801MB2031.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <VI1PR0801MB2031E8E4EDF2CE2F3D6BC401FF170@VI1PR0801MB2031.eurprd08.prod.outlook.com>

Ping
________________________________________
From: gcc-patches-owner@gcc.gnu.org <gcc-patches-owner@gcc.gnu.org> on behalf of Tamar Christina <Tamar.Christina@arm.com>
Sent: Tuesday, May 2, 2017 4:37:12 PM
To: GCC Patches
Cc: nd; Kyrylo Tkachov; Ramana Radhakrishnan; Richard Earnshaw; nickc@redhat.com
Subject: [PATCH][GCC][ARM] Adjust costs so udiv is preferred over sdiv when both are valid. [Patch (2/2)]

Hi All,

This patch adjusts the cost model so that when both sdiv and udiv are possible
it prefers udiv over sdiv. This was done by making sdiv slightly more expensive
instead of making udiv cheaper to keep the baseline costs of a division the same
as before.

Similar to aarch64 this patch along with my other two related mid-end changes
makes a big difference in division by constants.

Given:

int f2(int x)
{
  return ((x * x) % 300) + ((x * x) / 300);
}

we now generate

f2:
        mul     r3, r0, r0
        mov     r0, r3
        ldr     r1, .L3
        umull   r2, r3, r0, r1
        lsr     r2, r3, #5
        add     r3, r2, r2, lsl #2
        rsb     r3, r3, r3, lsl #4
        sub     r0, r0, r3, lsl #2
        add     r0, r0, r2
        bx      lr

as opposed to

f2:
        mul     r3, r0, r0
        mov     r0, r3
        ldr     r3, .L4
        push    {r4, r5}
        smull   r4, r5, r0, r3
        asr     r3, r0, #31
        rsb     r3, r3, r5, asr #5
        add     r2, r3, r3, lsl #2
        rsb     r2, r2, r2, lsl #4
        sub     r0, r0, r2, lsl #2
        add     r0, r0, r3
        pop     {r4, r5}
        bx      lr

Bootstrapped and reg tested on arm-none-eabi
with no regressions.

OK for trunk?

Thanks,
Tamar


gcc/
2017-05-02  Tamar Christina  <tamar.christina@arm.com>

        * config/arm/arm.c (arm_rtx_costs_internal): Make sdiv more expensive than udiv.


gcc/testsuite/
2017-05-02  Tamar Christina  <tamar.christina@arm.com>

        * gcc.target/arm/sdiv_costs_1.c: New.

  reply	other threads:[~2017-05-15  8:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 15:37 Tamar Christina
2017-05-15  8:33 ` Tamar Christina [this message]
2017-06-07  9:58   ` Tamar Christina
2017-06-07 10:04 ` Kyrill Tkachov
2017-06-07 10:15   ` Tamar Christina
2017-06-07 15:09     ` Tamar Christina
2017-06-09 10:11       ` Kyrill Tkachov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0801MB2031234BF60BF46E6CBE4FA6FFE10@VI1PR0801MB2031.eurprd08.prod.outlook.com \
    --to=tamar.christina@arm.com \
    --cc=Kyrylo.Tkachov@arm.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nd@arm.com \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).