This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, aarch64] additional bics patterns
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Ramana Radhakrishnan <Ramana dot Radhakrishnan at arm dot com>, Sandra Loosemore <sandra at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, "chrisj at nvidia dot com" <chrisj at nvidia dot com>
- Date: Thu, 13 Nov 2014 17:27:48 +0000
- Subject: Re: [patch, aarch64] additional bics patterns
- Authentication-results: sourceware.org; auth=none
- References: <5464E265 dot 6050008 at codesourcery dot com> <CAJA7tRaMwMQ2CHmPX9d8cK2QjKVhQxzVKL58q6wj0Fws78S=Hg at mail dot gmail dot com>
On 13/11/14 17:05, Ramana Radhakrishnan wrote:
> On Thu, Nov 13, 2014 at 4:55 PM, Sandra Loosemore
> <sandra@codesourcery.com> wrote:
>> This patch to the AArch64 back end adds a couple of additional bics patterns
>> to match code of the form
>>
>> if ((x & y) == x) ...;
>>
>> This is testing whether the bits set in x are a subset of the bits set in y;
>> or, that no bits in x are set that are not set in y. So, it is equivalent
>> to
>>
>> if ((x & ~y) == 0) ...;
>>
>> Presently this generates code like
>> and x21, x21, x20
>> cmp x21, x20
>> b.eq c0 <main+0xc0>
>>
>> and this patch allows it to be written more concisely as:
>> bics x21, x20, x21
>> b.eq c0 <main+0xc0>
>>
>> Since the bics instruction sets the condition codes itself, no explicit
>> comparison is required and the result of the bics computation can be
>> discarded.
>>
>> Regression-tested on aarch64-linux-gnu. OK to commit?
>
> Is this not a duplicate of
> https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00943.html ?
>
> regards
> Ramana
>
>>
>> -Sandra
>>
>>
>> 2014-11-12 Sandra Loosemore <sandra@codesourcery.com>
>> Chris Jones <chrisj@nvidia.com>
>>
>> gcc/
>> * config/aarch64/aarch64.md (*and<mode>3_compare_op1): New.
>> (*and<mode>3_compare_op2): New.
>>
>> gcc/testsuite/
>> * gcc.target/aarch64/bics_3.c: New.
>>
>>
>
I don't think so. However, I think it is something that should be
caught in generic simplification code
ie map ((a & b) == b) ==> ((~a & b) == 0), etc
Bit-clear operations are not that uncommon. Furthermore, A may be a
constant.
R.