This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][GCC][AARCH64]Adjust costs so udiv is preferred over sdiv when both are valid. [Patch (1/2)]


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:16 PM
To: GCC Patches
Cc: nd; Richard Earnshaw; Marcus Shawcroft; James Greenhalgh
Subject: [PATCH][GCC][AARCH64]Adjust costs so udiv is preferred over sdiv when both are valid. [Patch (1/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.

For 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     w0, w0, w0
        mov     w1, 33205
        movk    w1, 0x1b4e, lsl 16
        mov     w2, 300
        umull   x1, w0, w1
        lsr     x1, x1, 37
        msub    w0, w1, w2, w0
        add     w0, w0, w1
        ret

as opposed to

f2:
        mul     w0, w0, w0
        mov     w2, 33205
        movk    w2, 0x1b4e, lsl 16
        mov     w3, 300
        smull   x1, w0, w2
        umull   x2, w0, w2
        asr     x1, x1, 37
        sub     w1, w1, w0, asr 31
        lsr     x2, x2, 37
        msub    w0, w1, w3, w0
        add     w0, w0, w2
        ret

Bootstrapped and reg tested on aarch64-none-linux-gnu with no regressions.

OK for trunk?

Thanks,
Tamar


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

        * config/aarch64/aarch64.c (aarch64_rtx_costs): Make sdiv more expensive than udiv.
        Remove floating point cases from mod.

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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]