This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][PR 67328] Improve bitfield testing
- From: Yuri Gribov <tetra2005 at gmail dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, amodra at gmail dot com, rguenth at gcc dot gnu dot org
- Date: Wed, 25 Jan 2017 11:22:40 +0000
- Subject: Re: [PATCH][PR 67328] Improve bitfield testing
- Authentication-results: sourceware.org; auth=none
- References: <CAJOtW+5kuqdGOSZj1s2EXhiSf+UChU1ibHxMLUiDTB=-HDeBWA@mail.gmail.com> <alpine.LSU.2.20.1701251141410.12993@r111.fhfr.qr>
On Wed, Jan 25, 2017 at 10:49 AM, Richard Biener <rguenther@suse.de> wrote:
> On Wed, 25 Jan 2017, Yuri Gribov wrote:
>
>> Hi all,
>>
>> This fixes inefficient bitfield code reported in
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67328
>>
>> Bootstrapped and regtested on x86_64.
>>
>> Ok for trunk?
>
> This isn't a regression fix and thus not appropriate at this stage.
Definitely, just wanted to get initial round of comments. Thanks for
review, will get back with updated patch at stage 1.
> Some comments on the patch:
>
> +/* A & (2**N - 1) <= 2**K - 1 -> ~(A & (2**N - 2**K)
> + A & (2**N - 1) < 2**K -> ~(A & (2**N - 2**K)
> + A & (2**N - 1) >= 2**K -> A & (2**N - 2**K)
> + A & (2**N - 1) > 2**K - 1 -> A & (2**N - 2**K)
> + */
>
> you miss the != 0/== 0 in the result (and the ~ is redundant then).
>
> Note that A & (2**N - 1) >= 2**K should already have been simplified
> to A & (2**N - 1) > 2**K - 1 (we canonicalize to smaller constants).
>
> + (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && tree_fits_uhwi_p (@2) &&
> tree_fits_uhwi_p (@3))
> + (with
> + {
>
> I think you should restrict this to INTEGRAL_TYPE_P types.
>
> Please use wide-ints so you do not restrict yourself to fits_uhwi_p
> values.
>
> Thanks,
> Richard.