This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH GCC]Support BIT_AND_EXPR in scalar evolution
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: "Bin.Cheng" <amker dot cheng at gmail dot com>
- Cc: Bin Cheng <Bin dot Cheng at arm dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Wed, 20 Apr 2016 12:47:21 +0200
- Subject: Re: [PATCH GCC]Support BIT_AND_EXPR in scalar evolution
- Authentication-results: sourceware.org; auth=none
- References: <DB5PR08MB1144D1CAED8ED2FCBD894ADBE76C0 at DB5PR08MB1144 dot eurprd08 dot prod dot outlook dot com> <CAFiYyc1HXint6cezmM4JHD7351tfcYnEOSTULKL5xgK+gCs7-w at mail dot gmail dot com> <CAHFci2_q3z164zhjxXhnGgqFPSXSmRMy1t=JVsKBmnzES6JGDA at mail dot gmail dot com>
On Wed, Apr 20, 2016 at 12:22 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Wed, Apr 20, 2016 at 9:55 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Tue, Apr 19, 2016 at 7:00 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>>> Hi,
>>> Type conversion from integer to smaller unsigned type could be transformed into BIT_AND_EXPR in compilation. For example,
>>> int i;
>>> for (i = 0; i < n; i++)
>>> {
>>> unsigned char uc = (unsigned char) i; // transformed into X = i && 255, in which both X and i are of int type.
>>> b[uc] = 0;
>>> }
>>> X here could a valid SCEV if we can prove that loop doesn't iterate more than 255 times. In other words, if 'i' is SCEV and its value is in the range of representable set of type "unsigned char". This information could be available with -faggressive-loop-optimizations.
>>> This patch adds support for BIT_AND_EXPR in scalar evolution to handle such cases, as well as two new tests.
>>>
>>> Bootstrap and test on x86_64 & AArch64. Is it OK?
>>
>> Don't use cst_and_fits_in_hwi/int_cst_value - those are odd beasts.
>> Use tree_fits_uhwi_p / tree_to_uhwi.
>> Or just use wi::popcount and verify it against wi::clz.
> Thanks for reviewing, here is the updated patch. Regtest ongoing,
> shouldn't be any surprise though. Is it OK?
Ok.
Thanks,
Richard.
> Thanks,
> bin
>>
>> Richard.
>>
>>> Thanks,
>>> bin
>>>
>>> 2016-03-24 Bin Cheng <bin.cheng@arm.com>
>>>
>>> * tree-scalar-evolution.c (interpret_rhs_expr): Handle BIT_AND_EXPR.
>>>
>>> gcc/testsuite/ChangeLog
>>> 2016-03-24 Bin Cheng <bin.cheng@arm.com>
>>>
>>> * gcc.dg/tree-ssa/scev-11.c: New test.
>>> * gcc.dg/tree-ssa/scev-12.c: New test.
>>>