This is the mail archive of the gcc@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: [gsoc 2014] moving fold-const patterns to gimple


On Thu, Mar 20, 2014 at 9:52 PM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> On Wed, Mar 19, 2014 at 3:13 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Tue, Mar 18, 2014 at 9:04 AM, Prathamesh Kulkarni
>> <bilbotheelffriend@gmail.com> wrote:
>>> On Mon, Mar 17, 2014 at 2:22 PM, Richard Biener
>>> <richard.guenther@gmail.com> wrote:
>>>> On Sun, Mar 16, 2014 at 1:21 PM, Prathamesh Kulkarni
>>>> <bilbotheelffriend@gmail.com> wrote:
>>>>> In c_expr::c_expr, shouldn't OP_C_EXPR be passed to operand
>>>>> constructor instead of OP_EXPR ?
>>>>
>>>> Indeed - I have committed the fix.
>>>>
>>> Hi, I have attached an initial draft of my proposal.
>>> I would be grateful to receive your feedback.
>>
>> Ok, I had a look at the proposal and it is mostly fine.  I'd be more specific
>> on the deliverables, specifically
>>
>> 1) genmatch - program to read meta description and generate code to
>> simplify GENERIC and GIMPLE according to the pattern descriptions
>> using an algorithm not linear in the number of patterns
>>
>> 2) add patterns matched by tree-ssa-forwprop.c (and thus patterns
>> in fold-const.c it depends on) to the meta-description and perform
>> the simplifications of tree-ssa-forwprop.c in terms of the simplification API
>>
>> You will figure out that there are possibly a lot of patterns in fold-const.c
>> that forwprop depends on (I know mainly of all the comparison simplifications).
>>
>> For the Timeline I'd move e) as a sub-task of f) to June 28 - July 16,
>> eventually just dividing the weeks of July 17 - August 11 to that and
>> the following task.
>>
>> That is, the overall deliverable should be a tree-ssa-forwprop.c that is
>> (mostly) implemented in terms of patterns, ready for commit to trunk
>> during stage1.
>>
>> As for targeting GENERIC, useful testing coverage of that path will
>> come from for example re-writing fold-const.c:fold_comparison using
>> the GENERIC API of the pattern simplifier.
>>
>> The devil will be in the details (as always) ;)
>>
>> As Maxim said - make sure to register your proposal in-time, you
>> can always improve on it later.
>>
> Thanks for the feedback. I have uploaded it:
> http://www.google-melange.com/gsoc/proposal/public/google/gsoc2014/prathamesh3492/5629499534213120
> Would you like to suggest any further changes ?
> There are a few formatting glitches, I am fixing those.
>
> Could you help me point out how to write test-cases for transforms ?
> For example:
> /* Fold ~A + 1 -> -A */
> (match_and_simplify
>   (PLUS_EXPR (BIT_NOT_EXPR @0) @1)
>   if (@1 == integer_one_node)
>   (NEGATE_EXPR @0))
>
> Is the following test-case correctly written ?
> /* { dg-do compile } */
> /* { dg-options "-O -fdump-tree-forwprop" }  */
>
> int foo (int x)
> {
>   int temp1 = ~x;
>   int temp2 = temp1 + 1;
>   return temp2;
> }
>
> /* { dg-final { scan-tree-dump "temp* = -x*(D)" "forwprop1" } } */
> Shall that be (somewhat) correct ?

Yes, though the pattern to scan for may be somewhat fragile (generally
avoid using '*' there but use \[^\n\r\]* to avoid getting false matches across
newlines).

> (Unfortunately, I cannot check if I have written the test-case correctly,
> because I am in the middle of a bootstrap build.
> Is there a way to run test-cases on only stage-1 compiler ?
> I tried make check-cc1 RUNTESTFLAGS=dg.exp=tree-ssa/match-2.c but that
> did not work).

I usually do development on a separate build directory that I configure
like

CFLAGS=-g CXXFLAGS=-g /src/configure --disable-bootstrap
make CFLAGS=-g CXXFLAGS=-g

then I can test incremental changes by in gcc/ doing

> make cc1
> make check-gcc RUNTESTFLAGS="tree-ssa.exp=match-2.c"

Richard.

> forwprop output is:
> ;; Function foo (foo, funcdef_no=0, decl_uid=1743, symbol_order=0)
>
> gimple_match_and_simplified to temp2_3 = -x_1(D);
> foo (int x)
> {
>   int temp2;
>   int temp1;
>
>   <bb 2>:
>   temp1_2 = ~x_1(D);
>   temp2_3 = -x_1(D);
>   temp2_4 = temp2_3;
>   return temp2_4;
>
> }
>
> Thanks and Regards,
> Prathamesh
>
>> Thanks,
>> Richard.
>>
>>> Thanks and Regards,
>>> Prathamesh
>>>> Thanks,
>>>> Richard.
>>>>
>>>>> This caused segfault for patterns when "simplification" operand was
>>>>> only c_expr (patch attached).
>>>>>
>>>>> * genmatch.c (c_expr::c_expr): use OP_C_EXPR instead of OP_EXPR in
>>>>> call to operand constructor.


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