This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][GCC][AARCH64]Adjust costs so udiv is preferred over sdiv when both are valid. [Patch (1/2)]
- From: Tamar Christina <Tamar dot Christina at arm dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: nd <nd at arm dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>, "Marcus Shawcroft" <Marcus dot Shawcroft at arm dot com>, James Greenhalgh <James dot Greenhalgh at arm dot com>
- Date: Mon, 15 May 2017 08:33:06 +0000
- Subject: Re: [PATCH][GCC][AARCH64]Adjust costs so udiv is preferred over sdiv when both are valid. [Patch (1/2)]
- Authentication-results: sourceware.org; auth=none
- Authentication-results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com;
- Nodisclaimer: True
- References: <VI1PR0801MB2031451A1018AA38163513C7FF170@VI1PR0801MB2031.eurprd08.prod.outlook.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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.