[PATCH][Aarch64] Relational compare zero not merged into subtract
Michael Collison
Michael.Collison@arm.com
Thu Jun 1 23:54:00 GMT 2017
This patch improves code generation for relational compares against zero that are not merged into a subtract instruction. This patch improves the >= and < cases.
An example of the '<' case:
int lt (int x, int y)
{
if ((x - y) < 0)
return 10;
return 0;
}
Trunk generates:
lt:
sub w1, w0, w1
mov w0, 10
cmp w1, 0
csel w0, w0, wzr, lt
ret
With the patch we can eliminate the redundant subtract and now generate:
lt:
cmp w0, w1
mov w0, 10
csel w0, w0, wzr, mi
ret
Bootstrapped and tested on aarch64-linux-gnu. Okay for trunk?
2017-06-01 Michael Collison <michael.collison@arm.com>
* config/aarch64/aarch64-simd.md(aarch64_sub<mode>_compare0):
New pattern.
* testsuite/gcc.target/aarch64/cmp-2.c: New testcase.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr7261.patch.patch
Type: application/octet-stream
Size: 1192 bytes
Desc: pr7261.patch.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20170601/761fde2f/attachment.obj>
More information about the Gcc-patches
mailing list