This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, GCC] PR middle-end/55299, fold bitnot through ASR and rotates


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]