Re: [PATCH 00/17] warn & simplify negative or over-sized shifts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 21, 2018 at 7:33 AM Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
>
> The goal of this series is:
> * to give a correct & sensible warning on negative or over-sized shifts.
> * to add conservative simplification of such shifts.

Looks fine to me, but it did remind me that we do absolutely horribly
badly with one common "big shift" case.

Try linearizing this (obviously with -m64):

    int test(unsigned long x)
    {
        return x >> 32 >> 32;
    }

    int test2(unsigned long x)
    {
        return x >> 64;
    }

and note how the second case warns, but gives the right result. The
first case is "correct", but gets garbage code generation ;(

So I wish sparse had the proper simplification of "x >> C1 >> C2" into
"x >> (C1+C2)", but then the end result needs to work properly with
the big-shift case.

                 Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux