This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [GSoC] constant-folding pattern not fired
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Prathamesh Kulkarni <bilbotheelffriend at gmail dot com>
- Cc: Diego Novillo <dnovillo at google dot com>, gcc <gcc at gcc dot gnu dot org>, Maxim Kuvyrkov <maxim dot kuvyrkov at linaro dot org>
- Date: Mon, 18 Aug 2014 14:21:15 +0200
- Subject: Re: [GSoC] constant-folding pattern not fired
- Authentication-results: sourceware.org; auth=none
- References: <CAJXstsDzBjj0dNSFD1cvwYsA4QtURkCYk_GHDmw3CE3iwwpLTg at mail dot gmail dot com> <CAFiYyc2dyxupMAzq5kpt6e9AWppgOOAFH4cF0hBSHvd+z1Q9Vw at mail dot gmail dot com> <CAJXstsC00OXyhqB13ctCmn2bmFn7cGj0Tv1FE-sWpqHsGgt7OQ at mail dot gmail dot com>
On Mon, Aug 18, 2014 at 1:45 PM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> On Mon, Aug 18, 2014 at 4:37 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Sun, Aug 17, 2014 at 9:50 PM, Prathamesh Kulkarni
>> <bilbotheelffriend@gmail.com> wrote:
>>> Hi,
>>> Apparently this pattern is not getting fired (even in isolation).
>>>
>>> /* x % 1 -> 0 */
>>> (simplify
>>> (trunc_mod @0 integer_onep)
>>> { build_zero_cst (type); })
>>>
>>> I tried with this test-case:
>>> int f(int x)
>>> {
>>> int t1 = 1;
>>> int t2 = x % t1;
>>> return t2;
>>> }
>>>
>>> I get the following output in ccp1 dump file:
>>> http://pastebin.com/B6HjptkC
>>
>> It shows (and I also see that):
>>
>> Visiting statement:
>> t2_3 = x_2(D) % t1_1;
>> which is likely CONSTANT
>> Match-and-simplified x_2(D) % t1_1 to 0
>> Lattice value changed to CONSTANT 0. Adding SSA edges to worklist.
>>
>> so it works as expected? Or what do you miss?
>>
>> Note that the function is simplified all the way to return 0; and
>> intermediate statemens are removed.
> oops, I got mixed up -:)
> sorry for the noise.
>
> This patch adds the test-case for that pattern.
> testsuite/
> * match-constant-folding.c: Add new test-case.
Thanks - committed.
Richard.
> Thanks,
> Prathamesh
>
>>
>> Thanks,
>> Richard.
>>
>>> and the following output is generated in gimple-match.c:
>>> http://pastebin.com/tmi0cpxv
>>>
>>> I guess the generated code appears to be correct for the above pattern,
>>> so we are not doing anything wrong in genmatch ?
>>>
>>> Thanks,
>>> Prathamesh