public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH AARCH64] One-line tidy of bit-twiddle expression in aarch64.c
@ 2014-04-23 15:29 Alan Lawrence
  2014-04-29 12:48 ` Richard Earnshaw
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Lawrence @ 2014-04-23 15:29 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

This patch is a small tidy of a more-complicated expression that just flips a 
single bit and can thus be a simple XOR.

No regressions on aarch64-none-elf or aarch64_be-none-elf. (I've verified code 
is indeed exercised by dg-torture.exp vshuf-v*.c).

Also ok after applying TBL and testsuite patches in 
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01309.html and 
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00579.html.

gcc/ChangeLog:
2014-04-23  Alan Lawrence  <alan.lawrence@arm.com>

	* config/aarch64/aarch64.c (aarch64_expand_vec_perm_1): tidy bit-flip expression.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xor_tidy.patch --]
[-- Type: text/x-patch; name=xor_tidy.patch, Size: 491 bytes --]

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a3147ee..b879754 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -8124,7 +8124,7 @@ aarch64_expand_vec_perm_const_1 (struct expand_vec_perm_d *d)
       rtx x;
 
       for (i = 0; i < nelt; ++i)
-	d->perm[i] = (d->perm[i] + nelt) & (2 * nelt - 1);
+	d->perm[i] ^= nelt; /* Keep the same index, but in the other vector.  */
 
       x = d->op0;
       d->op0 = d->op1;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH AARCH64] One-line tidy of bit-twiddle expression in aarch64.c
  2014-04-23 15:29 [PATCH AARCH64] One-line tidy of bit-twiddle expression in aarch64.c Alan Lawrence
@ 2014-04-29 12:48 ` Richard Earnshaw
  2014-04-29 18:56   ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Earnshaw @ 2014-04-29 12:48 UTC (permalink / raw)
  To: Alan Lawrence; +Cc: gcc-patches

On 23/04/14 16:20, Alan Lawrence wrote:
> This patch is a small tidy of a more-complicated expression that just flips a 
> single bit and can thus be a simple XOR.
> 
> No regressions on aarch64-none-elf or aarch64_be-none-elf. (I've verified code 
> is indeed exercised by dg-torture.exp vshuf-v*.c).
> 
> Also ok after applying TBL and testsuite patches in 
> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01309.html and 
> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00579.html.
> 
> gcc/ChangeLog:
> 2014-04-23  Alan Lawrence  <alan.lawrence@arm.com>
> 
> 	* config/aarch64/aarch64.c (aarch64_expand_vec_perm_1): tidy bit-flip expression.
> 

s/tidy/Tidy/

It's not obvious from your description (or from the code, for that
matter) that for this to be valid nelt must be a power of 2.

I suggest that, above the loop, you put

	gcc_assert (nelt == (nelt & -nelt));

OK with those changes.

R.

> 
> xor_tidy.patch
> 
> 
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index a3147ee..b879754 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -8124,7 +8124,7 @@ aarch64_expand_vec_perm_const_1 (struct expand_vec_perm_d *d)
>        rtx x;
>  
>        for (i = 0; i < nelt; ++i)
> -	d->perm[i] = (d->perm[i] + nelt) & (2 * nelt - 1);
> +	d->perm[i] ^= nelt; /* Keep the same index, but in the other vector.  */
>  
>        x = d->op0;
>        d->op0 = d->op1;
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH AARCH64] One-line tidy of bit-twiddle expression in aarch64.c
  2014-04-29 12:48 ` Richard Earnshaw
@ 2014-04-29 18:56   ` Richard Henderson
  2014-05-02 15:12     ` Alan Lawrence
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2014-04-29 18:56 UTC (permalink / raw)
  To: Richard Earnshaw, Alan Lawrence; +Cc: gcc-patches

On 04/29/2014 05:42 AM, Richard Earnshaw wrote:
> On 23/04/14 16:20, Alan Lawrence wrote:
>> This patch is a small tidy of a more-complicated expression that just flips a 
>> single bit and can thus be a simple XOR.
>>
>> No regressions on aarch64-none-elf or aarch64_be-none-elf. (I've verified code 
>> is indeed exercised by dg-torture.exp vshuf-v*.c).
>>
>> Also ok after applying TBL and testsuite patches in 
>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01309.html and 
>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00579.html.
>>
>> gcc/ChangeLog:
>> 2014-04-23  Alan Lawrence  <alan.lawrence@arm.com>
>>
>> 	* config/aarch64/aarch64.c (aarch64_expand_vec_perm_1): tidy bit-flip expression.
>>
> 
> s/tidy/Tidy/
> 
> It's not obvious from your description (or from the code, for that
> matter) that for this to be valid nelt must be a power of 2.
> 
> I suggest that, above the loop, you put
> 
> 	gcc_assert (nelt == (nelt & -nelt));
> 
> OK with those changes.

I think it's sort of obvious from context that we're working with a vector.
And it also seems obvious that we won't have a vector without a power-of-two
number of elements.


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH AARCH64] One-line tidy of bit-twiddle expression in aarch64.c
  2014-04-29 18:56   ` Richard Henderson
@ 2014-05-02 15:12     ` Alan Lawrence
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Lawrence @ 2014-05-02 15:12 UTC (permalink / raw)
  To: Richard Henderson, Richard Earnshaw; +Cc: gcc-patches

Whilst I agree with Richard H that it is obvious, my feeling is that the 
assertion does no harm, so have committed rev 210005 with Richard E's changes.

--Alan

Richard Henderson wrote:
> On 04/29/2014 05:42 AM, Richard Earnshaw wrote:
>> On 23/04/14 16:20, Alan Lawrence wrote:
>>> This patch is a small tidy of a more-complicated expression that just flips a 
>>> single bit and can thus be a simple XOR.
>>>
>>> No regressions on aarch64-none-elf or aarch64_be-none-elf. (I've verified code 
>>> is indeed exercised by dg-torture.exp vshuf-v*.c).
>>>
>>> Also ok after applying TBL and testsuite patches in 
>>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01309.html and 
>>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00579.html.
>>>
>>> gcc/ChangeLog:
>>> 2014-04-23  Alan Lawrence  <alan.lawrence@arm.com>
>>>
>>> 	* config/aarch64/aarch64.c (aarch64_expand_vec_perm_1): tidy bit-flip expression.
>>>
>> s/tidy/Tidy/
>>
>> It's not obvious from your description (or from the code, for that
>> matter) that for this to be valid nelt must be a power of 2.
>>
>> I suggest that, above the loop, you put
>>
>> 	gcc_assert (nelt == (nelt & -nelt));
>>
>> OK with those changes.
> 
> I think it's sort of obvious from context that we're working with a vector.
> And it also seems obvious that we won't have a vector without a power-of-two
> number of elements.
> 
> 
> r~
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-02 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 15:29 [PATCH AARCH64] One-line tidy of bit-twiddle expression in aarch64.c Alan Lawrence
2014-04-29 12:48 ` Richard Earnshaw
2014-04-29 18:56   ` Richard Henderson
2014-05-02 15:12     ` Alan Lawrence

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).