This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Mikhail Maltsev <maltsevm at gmail dot com>
- Date: Tue, 17 May 2016 15:39:08 +0200
- Subject: Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- Authentication-results: sourceware.org; auth=none
- References: <572F6B36 dot 8050804 at gmail dot com> <alpine dot DEB dot 2 dot 20 dot 1605082148450 dot 2068 at laptop-mg dot saclay dot inria dot fr> <5731E816 dot 9050006 at gmail dot com> <alpine dot DEB dot 2 dot 20 dot 1605110924430 dot 1902 at laptop-mg dot saclay dot inria dot fr> <5735C0A4 dot 50106 at gmail dot com> <alpine dot DEB dot 2 dot 20 dot 1605131506540 dot 16902 at laptop-mg dot saclay dot inria dot fr>
On Fri, May 13, 2016 at 3:36 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Fri, 13 May 2016, Mikhail Maltsev wrote:
>
>>> I don't know if we might want some :c / single_use restrictions, maybe on
>>> the
>>> outer convert and the rshift/rotate.
>>>
>> I don't think :c can be used here.
>
>
> Oups, typo for :s.
>
>> As for :s, I added it, as you suggested.
>
>
> :s will be ignored when there is no conversion, but I think that's good
> enough for now.
Yeah. Doing :s twice as done in the patch works though.
>> Also, I tried to add some more test cases for rotate with conversions, but
>> unfortunately GCC does not recognize rotate pattern, when narrowing
>> conversions
>> are present.
>
>
> It is usually easier to split your expression into several assignments.
> Untested:
>
> int f(long long a, unsigned long n){
> long long b = ~a;
> unsigned long c = b;
> unsigned long d = ROLL (c, n);
> int e = d;
> return ~e;
> }
>
> this way the rotate pattern is detected early (generic) with no extra
> operations to confuse the compiler, while your new transformation will
> happen in gimple (most likely the first forwprop pass).
>
> The patch looks good to me, now wait for Richard's comments.
Are you sure narrowing conversions are valid for rotates?
(char)short_var <<r 8 == (char)short_var but short_var << r8 is its upper byte.
so at least for the conversion inside the rotate (and shift as well)
only nop-conversions
look valid to me.
Thanks,
Richard.
> --
> Marc Glisse
- References:
- [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates
- Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates